随笔分类 - Google
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l
阅读全文
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only
阅读全文
摘要:Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example Given the below binary tree: 1 / \ 2 3 ret
阅读全文
摘要:Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes. The lowest common ancestor is the node with larg
阅读全文
摘要:Design an iterator over a binary search tree with the following rules: Elements are visited in ascending order (i.e. an in-order traversal) next() and
阅读全文
摘要:Given a sequence of integers, find the longest increasing subsequence (LIS). You code should return the length of the LIS. Clarification What's the de
阅读全文
摘要: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 a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). Example Given binary tree {3,9,2
阅读全文
摘要: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
阅读全文
摘要:Search a 2D Matrix II Write an efficient algorithm that searches for a value in an m x n matrix, return the occurrence of it. This matrix has the foll
阅读全文
摘要:Given a string and an offset, rotate string by offset. (rotate from left to right) Given a string and an offset, rotate string by offset. (rotate from
阅读全文
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example Given lists: [ 2->4->null, null, -1->null ]
阅读全文
摘要:For an array A, if i < j, and A [i] > A [j], called (A [i], A [j]) is a reverse pair.return total of reverse pairs in A. For an array A, if i < j, and
阅读全文
摘要:Swap Nodes | Given a linked list, swap every two adjacent nodes and return its head. Example Given 1->2->3->4, you should return the list as 2->1->4->
阅读全文
摘要:Best Time to Buy and Sell Stock I Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted t
阅读全文
摘要: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
阅读全文
摘要:There are two sorted arrays A and B of size m and nrespectively. Find the median of the two sorted arrays. There are two sorted arrays A and B of size
阅读全文
摘要:Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back f
阅读全文
摘要:Combination Sum | Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to
阅读全文

浙公网安备 33010602011771号