Tic-tac-toe is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their…
Given a list of integers, an resonance number is the one with a frequency in the array equal to its value. Find out the biggest resonance number in the list.…
In mathematics, a harshad number (or Niven number) in a given number base is an integer that is divisible by the sum of its digits when written in that base. Harshad numbers in base n are also…
Given two strings of date, calculate how many days are there in between them. Sample Input: date1 = "2021-04-30", date2 = "2016-11-30" Sample Output: 1612 数据结构和算法:初级练习题 #50 – 日期间隔 给定两个日期字符串,计算它们之间相隔多少天。…
In number theory, a lucky number is a natural number in a set which is generated by a certain "sieve". This sieve is similar to the Sieve of Eratosthenes that…
Given a binary tree, find out all the only-child-nodes in it. A node is considered only-child-node if it has no sibling. Print out the values for those nodes in ascending…
Given a position on a chessboard, find out the color for it based on the image below. The position string starts with a letter from A to H, followed by…
Given a list of moving directions, among them 0° stands for east, 180° for west, 90° for north and 270° for south. The starting point is the Given a list…
Given an array of integers L, validate whether it is a mountain array or not. A mountain array satisfies the following rules: The size of the array n is equal…
On a Cartesian coordinate system, a rectangle can be described as a two-dimensional set: ( (x1, y1), (x2, y2)), where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate…