Find the sum of all left leaves in a given binary tree.继续阅读
A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.继续阅读
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.继续阅读
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).
Each LED represents a zero or one, with the least significant bit on the right.继续阅读
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …
n is positive and will fit within the range of a 32-bit signed integer
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0.继续阅读
Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.继续阅读
Given a positive integer n and you can do operations as follow:
If n is even, replace n with n/2.
If n is odd, you can replace n with either n + 1 or n – 1.
What is the minimum number of replacements needed for n to become 1?
Given an array of integers A and let n to be its length.
Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F on A as follow:
F(k) = 0 * Bk + 1 * Bk + … + (n-1) * Bk[n-1].
Calculate the maximum value of F(0), F(1), …, F(n-1).继续阅读