摘要:
Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]生成的过程为 (1) 横向生成 1,2 (2) 纵向生成 3,4 (3) 横向生成 5,6 (4) 纵向生成 7,8 (5) 生成 9public class ... 阅读全文
posted @ 2014-02-20 16:10
Razer.Lu
阅读(179)
评论(0)
推荐(0)
摘要:
Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie,"ACE" 阅读全文
posted @ 2014-02-20 16:06
Razer.Lu
阅读(192)
评论(0)
推荐(0)
摘要:
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Ref:http://fisherlei.blogspot.com/20... 阅读全文
posted @ 2014-02-20 15:24
Razer.Lu
阅读(236)
评论(0)
推荐(0)
摘要:
Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?Ref :http://fisherlei.blogspot.com/2013/11/leetcode-single-number-ii-solution.html[Thoughts] 阅读全文
posted @ 2014-02-20 14:45
Razer.Lu
阅读(210)
评论(0)
推荐(0)
摘要:
Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cases.Corner Cases:Did you consider the case wherepath="/../"?In this case, you should return&quo 阅读全文
posted @ 2014-02-20 13:57
Razer.Lu
阅读(253)
评论(0)
推荐(0)
摘要:
Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2014-02-20 13:42
Razer.Lu
阅读(189)
评论(0)
推荐(0)
摘要:
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.思路: 从 points[] 中依次取出一个点,然后依次和后面一个点组成一条直线。 y = ax+b;然后... 阅读全文
posted @ 2014-02-20 10:27
Razer.Lu
阅读(230)
评论(0)
推荐(0)
摘要:
Sort a linked list inO(nlogn) time using constant space complexity.Merge sort先根据mid node把list 分割为 单个 node ,然后merge/** * Definition for singly-linked l... 阅读全文
posted @ 2014-02-20 10:19
Razer.Lu
阅读(270)
评论(0)
推荐(0)

浙公网安备 33010602011771号