随笔分类 -  [LeetCode]

摘要:Problem:https://leetcode.com/problems/substring-with-concatenation-of-all-words/You are given a string,s, and a list of words,words, that are all of t... 阅读全文
posted @ 2015-08-21 00:46 airforce 阅读(193) 评论(0) 推荐(0)
摘要:The problem:Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are s... 阅读全文
posted @ 2015-02-27 07:11 airforce 阅读(145) 评论(0) 推荐(0)
摘要:The problem:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.My analysis:The idea behind ... 阅读全文
posted @ 2015-02-13 03:25 airforce 阅读(217) 评论(0) 推荐(0)
摘要:The problem:Given node P and node Q in a binary tree T.Find out the lowest common ancestor of the two nodes.Analysis:The answer of this problem could ... 阅读全文
posted @ 2015-02-11 01:09 airforce 阅读(280) 评论(0) 推荐(0)
摘要:The problem:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume ... 阅读全文
posted @ 2015-02-04 01:56 airforce 阅读(213) 评论(0) 推荐(0)
摘要:The problem:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return... 阅读全文
posted @ 2015-01-30 01:06 airforce 阅读(176) 评论(0) 推荐(0)
摘要:The problem:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous s... 阅读全文
posted @ 2015-01-29 11:46 airforce 阅读(170) 评论(0) 推荐(0)
摘要:The problem:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2... 阅读全文
posted @ 2015-01-28 11:10 airforce 阅读(179) 评论(0) 推荐(0)
摘要:The problem:Sort a linked list using insertion sort.My analysis:The idea behind this solution is easy, but the mainipulation over linkedlist is hard a... 阅读全文
posted @ 2015-01-28 01:52 airforce 阅读(256) 评论(0) 推荐(0)
摘要:The problem:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a... 阅读全文
posted @ 2015-01-21 04:30 airforce 阅读(148) 评论(0) 推荐(0)
摘要:The problem:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each... 阅读全文
posted @ 2015-01-20 13:14 airforce 阅读(135) 评论(0) 推荐(0)
摘要:The problem:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and i... 阅读全文
posted @ 2015-01-20 11:18 airforce 阅读(237) 评论(0) 推荐(0)
摘要:The question:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using ex... 阅读全文
posted @ 2015-01-20 02:25 airforce 阅读(167) 评论(0) 推荐(0)
摘要:The problem: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 in... 阅读全文
posted @ 2015-01-18 04:59 airforce 阅读(167) 评论(0) 推荐(0)
摘要:The question:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?S... 阅读全文
posted @ 2015-01-18 04:21 airforce 阅读(158) 评论(0) 推荐(0)
摘要:The question:Single NumberGiven an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a... 阅读全文
posted @ 2015-01-17 01:29 airforce 阅读(202) 评论(0) 推荐(0)
摘要:The problem:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the ... 阅读全文
posted @ 2015-01-17 01:03 airforce 阅读(798) 评论(0) 推荐(0)
摘要:The problem:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2... 阅读全文
posted @ 2015-01-16 01:35 airforce 阅读(219) 评论(0) 推荐(0)
摘要:The problem:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the l... 阅读全文
posted @ 2015-01-16 00:01 airforce 阅读(136) 评论(0) 推荐(0)
摘要:The problem:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals we... 阅读全文
posted @ 2015-01-15 03:42 airforce 阅读(170) 评论(0) 推荐(0)