文章分类 -  leetcode

1 2 3 4 5 ··· 8 下一页
摘要:#include <iostream>#include <vector>using namespace std;//最小堆void adjust(vector<int> &data, int i, int size) { int left = i*2+1; if(left>=size) return 阅读全文
posted @ 2016-07-01 11:10 purejade 阅读(84) 评论(0) 推荐(0)
摘要:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed num... 阅读全文
posted @ 2015-01-13 23:06 purejade 阅读(109) 评论(0) 推荐(0)
摘要: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 out in a... 阅读全文
posted @ 2015-01-09 14:36 purejade 阅读(101) 评论(0) 推荐(0)
摘要:Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Credits:Special thanks to@tsf... 阅读全文
posted @ 2014-12-30 20:02 purejade 阅读(64) 评论(0) 推荐(0)
摘要:Related to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A ... 阅读全文
posted @ 2014-12-29 15:25 purejade 阅读(130) 评论(0) 推荐(0)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating,... 阅读全文
posted @ 2014-12-29 15:14 purejade 阅读(121) 评论(0) 推荐(0)
摘要: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 that the arr... 阅读全文
posted @ 2014-12-23 19:39 purejade 阅读(85) 评论(0) 推荐(0)
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->... 阅读全文
posted @ 2014-12-23 19:38 purejade 阅读(111) 评论(0) 推荐(0)
摘要:Compare two version numbersversion1andversion1.Ifversion1>version2return 1, ifversion1 value1; vector value2; string tmpvalue; wh... 阅读全文
posted @ 2014-12-16 16:08 purejade 阅读(113) 评论(0) 推荐(0)
摘要:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort... 阅读全文
posted @ 2014-12-16 15:06 purejade 阅读(82) 评论(0) 推荐(0)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文
posted @ 2014-12-16 15:05 purejade 阅读(89) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2014-12-16 15:03 purejade 阅读(79) 评论(0) 推荐(0)
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文
posted @ 2014-12-16 15:02 purejade 阅读(111) 评论(0) 推荐(0)
摘要:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.... 阅读全文
posted @ 2014-12-16 15:00 purejade 阅读(77) 评论(0) 推荐(0)
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 ... 阅读全文
posted @ 2014-12-16 14:59 purejade 阅读(83) 评论(0) 推荐(0)
摘要:Two of the nodes of a Binary Search Tree (BST) are swapped. Fix (or correct) the BST.Input Tree: 10 / \ 5 8 / \ 2 ... 阅读全文
posted @ 2014-10-28 19:16 purejade 阅读(146) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2014-10-05 20:02 purejade 阅读(87) 评论(0) 推荐(0)
摘要:Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem stat... 阅读全文
posted @ 2014-10-05 10:36 purejade 阅读(109) 评论(0) 推荐(0)
摘要:Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest... 阅读全文
posted @ 2014-10-05 10:30 purejade 阅读(88) 评论(0) 推荐(0)
摘要:Given an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm should ru... 阅读全文
posted @ 2014-09-08 23:14 purejade 阅读(92) 评论(0) 推荐(0)

1 2 3 4 5 ··· 8 下一页