07 2016 档案

Word Ladder
摘要:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, 阅读全文

posted @ 2016-07-31 19:30 Sheryl Wang 阅读(155) 评论(0) 推荐(0) 编辑

Subsets II
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate sub 阅读全文

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

Subsets
摘要:Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = 阅读全文

posted @ 2016-07-25 16:58 Sheryl Wang 阅读(130) 评论(0) 推荐(0) 编辑

Maximum Gap
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear time/space. Return 阅读全文

posted @ 2016-07-23 20:00 Sheryl Wang 阅读(143) 评论(0) 推荐(0) 编辑

Continuous Subarray Sum II
摘要:Given an circular integer array (the next element of the last element is the first element), find a continuous subarray in it, where the sum of number 阅读全文

posted @ 2016-07-23 16:34 Sheryl Wang 阅读(398) 评论(0) 推荐(0) 编辑

Continuous Subarray Sum
摘要:Given an integer array, find a continuous subarray where the sum of numbers is the biggest. Your code should return the index of the first number and 阅读全文

posted @ 2016-07-22 23:01 Sheryl Wang 阅读(163) 评论(0) 推荐(0) 编辑

Submatrix Sum
摘要:Given an integer matrix, find a submatrix where the sum of numbers is zero. Your code should return the coordinate of the left-up and right-down numbe 阅读全文

posted @ 2016-07-22 22:56 Sheryl Wang 阅读(376) 评论(0) 推荐(0) 编辑

Maximum Product Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4],t 阅读全文

posted @ 2016-07-22 22:47 Sheryl Wang 阅读(129) 评论(0) 推荐(0) 编辑

Backpack III 完全背包
摘要:Given n kind of items with size Ai and value Vi( each item has an infinite number available) and a backpack with size m. What's the maximum value can 阅读全文

posted @ 2016-07-18 15:56 Sheryl Wang 阅读(286) 评论(0) 推荐(0) 编辑

Walls and Gates
摘要:You are given a m x n 2D grid initialized with these three possible values. Fill each empty room with the distance to its nearest gate. If it is impos 阅读全文

posted @ 2016-07-17 15:55 Sheryl Wang 阅读(209) 评论(0) 推荐(0) 编辑

Minimum Window Substring
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECOD 阅读全文

posted @ 2016-07-16 23:02 Sheryl Wang 阅读(152) 评论(0) 推荐(0) 编辑

Minimum Size Subarray Sum
摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 阅读全文

posted @ 2016-07-16 22:16 Sheryl Wang 阅读(180) 评论(0) 推荐(0) 编辑

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

posted @ 2016-07-15 22:16 Sheryl Wang 阅读(138) 评论(0) 推荐(0) 编辑

Closest Binary Search Tree Value II
摘要:Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floati 阅读全文

posted @ 2016-07-13 21:59 Sheryl Wang 阅读(289) 评论(0) 推荐(0) 编辑

Closest Binary Search Tree Value
摘要:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati 阅读全文

posted @ 2016-07-13 21:30 Sheryl Wang 阅读(220) 评论(0) 推荐(0) 编辑

Find Leaves of Binary Tree
摘要:Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Example:Given bi 阅读全文

posted @ 2016-07-13 21:06 Sheryl Wang 阅读(257) 评论(0) 推荐(0) 编辑

Largest BST Subtree
摘要:Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it. Not 阅读全文

posted @ 2016-07-13 10:59 Sheryl Wang 阅读(181) 评论(0) 推荐(0) 编辑

Invert Binary Tree
摘要:Invert a binary tree. to 反转二叉树,其实就是自顶向下递归翻转.代码如下: 阅读全文

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

Recover Binary Search Tree
摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space 阅读全文

posted @ 2016-07-11 17:12 Sheryl Wang 阅读(129) 评论(0) 推荐(0) 编辑

Inorder Successor in BST
摘要:Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in 阅读全文

posted @ 2016-07-11 15:22 Sheryl Wang 阅读(392) 评论(0) 推荐(0) 编辑

Binary Tree Inorder Traversal
摘要:基础功底,此类模板以后一次总结: 阅读全文

posted @ 2016-07-11 09:52 Sheryl Wang 阅读(109) 评论(0) 推荐(0) 编辑

Nuts & Bolts Problem
摘要:Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping between nuts and bolts. Comparison of a nut to ano 阅读全文

posted @ 2016-07-09 21:47 Sheryl Wang 阅读(845) 评论(0) 推荐(0) 编辑

Sliding Window Median
摘要:Given an array of n integer with duplicate number, and a moving window(size k), move the window at each iteration from the start of the array, find th 阅读全文

posted @ 2016-07-09 11:56 Sheryl Wang 阅读(224) 评论(0) 推荐(0) 编辑

Sliding Window Maximum
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the knumb 阅读全文

posted @ 2016-07-09 11:37 Sheryl Wang 阅读(217) 评论(0) 推荐(0) 编辑

Find Median from Data Stream
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文

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

hashheap python 实现
摘要:这个hashheap的实现可以既可以是最大堆,也可以是最小堆,同时因为hash表中存的value是在heap数组中的index和这个key值的数目,所以可以处理重复数字.关键在于siftup和siftdown的非递归实现.siftdown相当于heapify,但是之前只使用过递归版本. 阅读全文

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

Find the Weak Connected Component in the Directed Graph
摘要:Find the number Weak Connected Component in the directed graph. Each node in the graph contains a label and a list of its neighbors. (a connected set 阅读全文

posted @ 2016-07-06 14:43 Sheryl Wang 阅读(244) 评论(0) 推荐(0) 编辑

Word Search II
摘要:Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adja 阅读全文

posted @ 2016-07-05 15:07 Sheryl Wang 阅读(136) 评论(0) 推荐(0) 编辑

Word Search
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文

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

Add and Search Word - Data structure design
摘要:Design a data structure that supports the following two operations: search(word) can search a literal word or a regular expression string containing o 阅读全文

posted @ 2016-07-04 15:49 Sheryl Wang 阅读(173) 评论(0) 推荐(0) 编辑

Implement Trie (Prefix Tree)
摘要:Implement a trie with insert, search, and startsWith methods. Note: You may assume that all inputs are consist of lowercase letters a-z. 终于进军trie树,tri 阅读全文

posted @ 2016-07-04 10:11 Sheryl Wang 阅读(167) 评论(0) 推荐(0) 编辑

Graph Valid Tree
摘要:Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges mak 阅读全文

posted @ 2016-07-03 22:21 Sheryl Wang 阅读(236) 评论(0) 推荐(0) 编辑

Maximum Subarray III
摘要:Given an array of integers and a number k, find k non-overlapping subarrays which have the largest sum. The number in each subarray should be contiguo 阅读全文

posted @ 2016-07-02 17:00 Sheryl Wang 阅读(271) 评论(0) 推荐(0) 编辑

Maximum Subarray II
摘要:Given an array of integers, find two non-overlapping subarrays which have the largest sum. The number in each subarray should be contiguous. Return th 阅读全文

posted @ 2016-07-02 16:51 Sheryl Wang 阅读(125) 评论(0) 推荐(0) 编辑

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

导航

统计

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