Given a collection of distinct numbers, return all possible permutations.
Example:
[1,2,3] have the following permutations:
1 2 3 4 5 6 7 8 |
|
Given a collection of distinct numbers, return all possible permutations.
[1,2,3] have the following permutations:
1 2 3 4 5 6 7 8 |
|
Reverse a linked list from position m to n. Do it in-place and in one-pass.
Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Given m, n satisfy the following condition:
1 ≤ m ≤ n ≤ length of list.
Given an index k, return the kth row of the Pascal’s triangle.
given k = 3, Return [1,3,3,1].
Could you optimize your algorithm to use only O(k) extra space?
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j is at most k.
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
nums = [1, 2, 3] target = 4
The possible combination ways are:
1 2 3 4 5 6 7 |
|
Different sequences are counted as different combinations.
Therefore the output is 7.
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
For example, given
s = “leetcode”, dict = [“leet”, “code”].
Return true because “leetcode” can be segmented as “leet code”.
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).
Given binary tree [3,9,20,null,null,15,7],
1 2 3 4 5 |
|
return its zigzag level order traversal as:
1 2 3 4 5 |
|
Implement a trie with insert, search, and startsWith methods.
You may assume that all inputs are consist of lowercase letters a-z.
Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).
Given binary tree [3,9,20,null,null,15,7],
1 2 3 4 5 |
|
return its level order traversal as:
1 2 3 4 5 |
|
Given an integer, write a function to determine if it is a powero two.