Given aContinue reading “[Leetcode]421. Maximum XOR of Two Numbers in an Array”non-emptyarray of numbers, a_{0}, a_{1}, a_{2}, … , a_{n-1}, where 0 ≤ a_{i}< 2^{31}. Find the maximum result of a_{i}XOR a_{j}, where 0 ≤i,j<n. Could you do this in O(n) runtime?

## [Leetcode]1558. Minimum Numbers of Function Calls to Make Target Array

Your task is to form an integer arrayContinue reading “[Leetcode]1558. Minimum Numbers of Function Calls to Make Target Array”`nums`

from an initial array of zeros`arr`

that is the same size as`nums`

. Return the minimum number of function calls to make`nums`

from`arr`

. The answer is guaranteed to fit in a 32-bit signed integer.

## [Leetcode]1022. Sum of Root To Leaf Binary Numbers

Given a binary tree, each node has valueContinue reading “[Leetcode]1022. Sum of Root To Leaf Binary Numbers”`0`

or`1`

. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is`0 -> 1 -> 1 -> 0 -> 1`

, then this could represent`01101`

in binary, which is`13`

. For all leaves in the tree, consider the numbers represented by the path from the root to that leaf. Return the sum of these numbers.

## [Leetcode]1286. Iterator for Combination

Design an Iterator class, which has: A constructor that takes a stringContinue reading “[Leetcode]1286. Iterator for Combination”`characters`

ofsorted distinctlowercase English letters and a number`combinationLength`

as arguments. A functionnext()that returns the next combination of length`combinationLength`

inlexicographical order. A functionhasNext()that returns`True`

if and only if there exists a next combination.Constraints:`1 <= combinationLength <= characters.length <= 15`

There will be at most`10^4`

function calls per test. It's guaranteed that all calls of the function`next`

are valid.

## [Leetcode]260. Single Number III

Given an array of numbersContinue reading “[Leetcode]260. Single Number III”`nums`

, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.Example:Input:`[1,2,1,3,2,5]`

Output:`[3,5]`

## [Leetcode]190. Reverse Bits

Reverse bits of a given 32 bits unsigned integer.Continue reading “[Leetcode]190. Reverse Bits”Example 1:Input:00000010100101000001111010011100Output:00111001011110000010100101000000

## [Leetcode problems]137. Single Number II

Given aContinue reading “[Leetcode problems]137. Single Number II”non-emptyarray of integers, every element appearsthreetimes except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?Example 1:Input:[2,2,3,2]Output:3

## [Leetcode problems]136. Single Number

Given aContinue reading “[Leetcode problems]136. Single Number”non-emptyarray of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?Example 1:Input:[2,2,1]Output:1