随笔分类 - [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...
阅读全文
摘要: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...
阅读全文
摘要:The problem:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.My analysis:The idea behind ...
阅读全文
摘要: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 ...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:The problem:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:The question:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?S...
阅读全文
摘要:The question:Single NumberGiven an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:The problem:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals we...
阅读全文

浙公网安备 33010602011771号