随笔分类 - [LeetCode]
摘要:int curInc;HashMap incMap;Stack stack;public SuperStack() { this.curInc = 0; this.incMap = new HashMap(); this.stack = new Stack();} p...
阅读全文
摘要:Problem:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all...
阅读全文
摘要:Problem:Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Fo...
阅读全文
摘要:Problem:Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You ...
阅读全文
摘要:Problem:Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators a...
阅读全文
摘要:Problem:Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible repres...
阅读全文
摘要:Problem:Given an unsorted arraynums, reorder itin-placesuch thatnums[0] = nums[2] = nums[2] = nums[i+1]Note: i is an odd number. Solution 1:public cla...
阅读全文
摘要:Problem:Given a non-empty binary search tree and a target value, findkvalues in the BST that are closest to the target.Note:Given target value is a fl...
阅读全文
摘要:Problem:Numbers can be regarded as product of its factors. For example,8 = 2 x 2 x 2; = 2 x 4.Write a function that takes an integernand return all p...
阅读全文
摘要:Problem:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid ...
阅读全文
摘要:Problem:Given two strings S and T, determine if they are both one edit distance apart.General Analysis:This problem is not hard. However, to write out...
阅读全文
摘要:Problem:Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome y...
阅读全文
摘要:Problem:Suppose you are at a party withnpeople (labeled from0ton - 1) and among them, there may exist one celebrity. The definition of a celebrity is ...
阅读全文
摘要:Problem:The API:int read4(char *buf)reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it...
阅读全文
摘要:Problem:Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, fl...
阅读全文
摘要:Problem:A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you ...
阅读全文
摘要:Problem: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...
阅读全文
摘要:Problem:Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.For example...
阅读全文
摘要:Problem:Given a strings, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could ...
阅读全文
摘要:Problem:Given two 1d vectors, implement an iterator to return their elements alternately.For example, given two 1d vectors:v1 = [1, 2]v2 = [3, 4, 5, 6...
阅读全文

浙公网安备 33010602011771号