08 2016 档案

Convert Sorted Array to Binary Search Tree
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 阅读全文

posted @ 2016-08-30 17:20 Sheryl Wang 阅读(102) 评论(0) 推荐(0) 编辑

First Missing Positive
摘要:Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm 阅读全文

posted @ 2016-08-30 10:34 Sheryl Wang 阅读(107) 评论(0) 推荐(0) 编辑

Sudoku Solver
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be 阅读全文

posted @ 2016-08-29 21:24 Sheryl Wang 阅读(140) 评论(0) 推荐(0) 编辑

Merge Intervals
摘要:Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. 这题和Inser 阅读全文

posted @ 2016-08-29 16:54 Sheryl Wang 阅读(139) 评论(0) 推荐(0) 编辑

Insert Interval
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文

posted @ 2016-08-29 16:16 Sheryl Wang 阅读(158) 评论(0) 推荐(0) 编辑

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 T. The same repeat 阅读全文

posted @ 2016-08-28 10:13 Sheryl Wang 阅读(150) 评论(0) 推荐(0) 编辑

Trapping Rain Water II
摘要:Given n x m non-negative integers representing an elevation map 2d where the area of each cell is 1 x 1, compute how much water it is able to trap aft 阅读全文

posted @ 2016-08-27 16:54 Sheryl Wang 阅读(155) 评论(0) 推荐(0) 编辑

Kth Largest in N Arrays
摘要:Find K-th largest element in N arrays. Example In n=2 arrays [[9,3,2,4,7],[1,2,3,4,8]], the 3rd largest element is 7. In n=2 arrays [[9,3,2,4,8],[1,2, 阅读全文

posted @ 2016-08-27 16:33 Sheryl Wang 阅读(296) 评论(0) 推荐(0) 编辑

Spiral Matrix
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: You 阅读全文

posted @ 2016-08-27 16:18 Sheryl Wang 阅读(142) 评论(0) 推荐(0) 编辑

Search a 2D Matrix
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文

posted @ 2016-08-21 22:25 Sheryl Wang 阅读(111) 评论(0) 推荐(0) 编辑

Binary Postorder Traversal
摘要:Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. 后续遍历二叉树,主要是使用栈来非递归实 阅读全文

posted @ 2016-08-21 17:14 Sheryl Wang 阅读(124) 评论(0) 推荐(0) 编辑

Search in Rotated Sorted Array II
摘要:Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a functi 阅读全文

posted @ 2016-08-21 12:12 Sheryl Wang 阅读(147) 评论(0) 推荐(0) 编辑

Pow(x, n)
摘要:Implement pow(x, n) 这题用二分做,思路很明确,但是具体怎么做很有trick. 首先是n可能为INT_MIN ,如果将n直接取绝对值,则会溢出,另外,此时直接求分母,最后再求倒数,也可能在求分母的过程中溢出. 所以比较好的办法每次需要乘元素的时候乘以1/x(n<0)时. 大坑:py 阅读全文

posted @ 2016-08-17 11:45 Sheryl Wang 阅读(183) 评论(0) 推荐(0) 编辑

Insertion Sort List
摘要:Sort a linked list using insertion sort. 这道题目要求插入排序,插入排序的做法的正常做法是,对于当前要处理的数字,朝前查找在已排序数组中的位置. 对于单向链表而言,无法朝前走,所以一个替换的选择是从头朝后走.直到后面的节点值大于当前处理的节点. 值得注意的有两 阅读全文

posted @ 2016-08-16 20:29 Sheryl Wang 阅读(116) 评论(0) 推荐(0) 编辑

Word Break II
摘要:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such p 阅读全文

posted @ 2016-08-15 21:48 Sheryl Wang 阅读(180) 评论(0) 推荐(0) 编辑

Decode Ways
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文

posted @ 2016-08-15 15:25 Sheryl Wang 阅读(118) 评论(0) 推荐(0) 编辑

Substring with Concatenation of All Words I
摘要:如题,这题需要思考的是复杂度 阅读全文

posted @ 2016-08-15 11:19 Sheryl Wang 阅读(111) 评论(0) 推荐(0) 编辑

Generate Parentheses
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: 这 阅读全文

posted @ 2016-08-12 14:16 Sheryl Wang 阅读(123) 评论(0) 推荐(0) 编辑

Letter Combinations of a Phone Number
摘要:Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telepho 阅读全文

posted @ 2016-08-12 10:33 Sheryl Wang 阅读(151) 评论(0) 推荐(0) 编辑

SubTree
摘要:You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of 阅读全文

posted @ 2016-08-07 17:33 Sheryl Wang 阅读(148) 评论(0) 推荐(0) 编辑

Odd Even Linked List
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文

posted @ 2016-08-07 11:18 Sheryl Wang 阅读(121) 评论(0) 推荐(0) 编辑

Partition Array by Odd and Even
摘要:Partition an integers array into odd number first and even number second. 剑指offer的一道题,把所有奇数移动到偶数前面,其实是partition的双端解法,利用双指针。先检测两边合格的元素,都不合格,则交换,继续。 需要注 阅读全文

posted @ 2016-08-07 11:03 Sheryl Wang 阅读(192) 评论(0) 推荐(0) 编辑

导航

点击右上角即可分享
微信分享提示