- 博客(28)
- 资源 (12)
- 收藏
- 关注
原创 Path in Matrix
Given a N X N matrix Matrix[N][N] of positive integers. There are only three possible moves from a cell Matrix[r][c].1. Matrix[r+1][c]2. Matrix[r+1][c-1]3. Matrix[r+1][c+1]Starting f
2017-01-18 04:23:36 412
原创 Reach a given score
Consider a game where a player can score 3 or 5 or 10 points in a move. Given a total score n, find number of distinct combinations to reach the given score.Input:The first line of input con
2017-01-16 06:29:10 601
原创 Unique BST's
Given an interger N, how many structurally unique binary search trees are there that store values 1...N?For example, for N = 2, there are 2 unique BSTs 1 2
2017-01-16 06:07:16 454
原创 Count ways to N'th Stair(Order does not matter)
There are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can reach the top (order doe
2017-01-16 05:45:25 725
原创 Group Shifted Strings
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:"abc" -> "bcd" -> ... -> "xyz"Given a l
2017-01-15 01:47:39 412
原创 4Sum II
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same l
2017-01-13 09:17:25 397
原创 Design Tic-Tac-Toe
Design a Tic-tac-toe game that is played between two players on a n x n grid.You may assume the following rules:A move is guaranteed to be valid and is placed on an empty block.Once a winning
2017-01-13 08:52:22 417
原创 Binary Tree Vertical Order Traversal
en a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).If two nodes are in the same row and column, the order should be from left to
2017-01-13 02:24:48 331
原创 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:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You
2017-01-11 09:57:44 213
原创 Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?这种题不希望再错了。明明很简单的。其实leetcode上面的题说白了就是能不能跟你理解的类型联系起来。如果知道类型了,而且也有思路,写不对,很气的。这道
2017-01-10 04:48:09 237
原创 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 = [1,2,3], a solution is:[ [3], [1],
2017-01-10 03:43:01 279
原创 Paint House
There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the ho
2017-01-09 13:57:52 369
原创 Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O
2017-01-09 13:53:52 255
原创 Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "
2017-01-09 12:55:03 211
原创 Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].Credits:好久没做的题,一上来有点小慌,觉得没有印象可能不能一下子写出来。不过还好。看来
2017-01-09 10:25:35 187
原创 Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get
2017-01-09 04:50:19 256
原创 Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next()
2017-01-08 12:34:34 229
转载 Binary Tree Preorder Traversal & Binary Tree Inorder Traversal & Binary Tree Postorder Traversal
这一篇补充下leetcode上的二叉树的三种遍历的迭代实现。基本上是参照往上的来的。写的比较清晰 链接:https://segmentfault.com/a/1190000003532763 自己都实现了一遍。这种基础的算法还是要牢固一些。第一题前序遍历:Given a binary tree, return the preorder traversal of its node
2017-01-08 04:04:37 252
原创 Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [
2017-01-07 11:29:06 272
原创 Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.继续填坑。这道题应该使用空间复杂度O(1)来解。思路是用两个变量分别记录第一行跟第一列时候有0; 因为这个方法需要使用第一行跟第一列记录0行跟列为0的情况,所以会改变这一行,这一列的信息,所以在
2017-01-07 06:06:39 189
原创 Game of Life
According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board with m
2017-01-07 05:21:01 320
原创 Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?有一种只需要
2017-01-07 03:14:42 193
原创 Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]基础题。注意下边界条件。i = 0 的时候只有一
2017-01-07 02:48:48 163
原创 Palindrome Permutation II
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.For example:Given s = "aabb", return ["
2017-01-05 04:00:42 314
原创 Design Twitter
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user's news feed. Your design should support the fo
2017-01-05 02:16:13 283
原创 Minimum Genetic Mutation
A gene string can be represented by an 8-character long string, with choices from "A", "C", "G", "T".Suppose we need to investigate about a mutation (mutation from "start" to "end"), where ONE mut
2017-01-04 12:12:44 784
原创 Word Break
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, givens = "leetcode",dict = ["leet"
2017-01-04 11:28:49 225
原创 Walls and Gates
You are given a m x n 2D grid initialized with these three possible values.-1 - A wall or an obstacle.0 - A gate.INF - Infinity means an empty room. We use the value 231 - 1 = 2147483647 to repr
2017-01-04 05:14:33 291
Angular4 英文教材 参考代码
2017-11-07
Angular 股票管理
2017-08-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人