随笔分类 - Level 2
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept
阅读全文
摘要:Given inorder and postorder traversal of a tree, construct the binary tree. Notice You may assume that duplicates do not exist in the tree. Given inor
阅读全文
摘要:Given two strings, find the longest common subsequence (LCS). Your code should return the length of LCS. Example For "ABCD" and "EDCA", the LCS is "A"
阅读全文
摘要:Reverse Words in a String I Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the".
阅读全文
摘要:Maximum Subarray Given an array of integers, find a contiguous subarray which has the largest sum. Notice The subarray should contain at least one num
阅读全文
摘要:For a given source string and a target string, you should output the first index(from 0) of target string in source string. If target does not exist i
阅读全文
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all
阅读全文
摘要:Given a list of non negative integers, arrange them such that they form the largest number. Notice The result may be very large, so you need to return
阅读全文
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or
阅读全文
摘要:Backpack | Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack? Given n items with size Ai, a
阅读全文
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Clarification Your algorithm should run in O(n) com
阅读全文
摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers.
阅读全文
摘要:3 Sum Given an array S of n integers, are there elements a, b, c in Ssuch that a + b + c = 0? Find all unique triplets in the array which gives the su
阅读全文
摘要:Two Sum I Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of
阅读全文
摘要:Given a collection of distinct numbers, return all possible permutations. For example,[1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,
阅读全文
摘要:Given a singly linked list L: L0 → L1 → … → Ln-1 → Ln reorder it to: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → … Example Given 1->2->3->4->null, reorder it to
阅读全文
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy
阅读全文
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Example 2 1->2->3 => / \ 1 3 分析:非常简单,用递归
阅读全文
摘要:Find the nth to last element of a singly linked list. The minimum number of nodes in list is n. Find the nth to last element of a singly linked list.
阅读全文
摘要:Given a list, rotate the list to the right by k places, where k is non-negative. Given a list, rotate the list to the right by k places, where k is no
阅读全文

浙公网安备 33010602011771号