摘要: 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 @ 2015-02-08 23:59 Vae永Silence 阅读(168) 评论(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 @ 2015-02-08 23:57 Vae永Silence 阅读(120) 评论(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 @ 2015-02-08 23:53 Vae永Silence 阅读(126) 评论(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 @ 2015-02-08 23:44 Vae永Silence 阅读(344) 评论(0) 推荐(0) 编辑
摘要: Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1num2)return 1; } return 0; }}; 阅读全文
posted @ 2015-02-08 23:33 Vae永Silence 阅读(151) 评论(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 @ 2015-02-08 23:30 Vae永Silence 阅读(116) 评论(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 @ 2015-02-08 23:28 Vae永Silence 阅读(116) 评论(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 @ 2015-02-08 23:26 Vae永Silence 阅读(131) 评论(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 @ 2015-02-08 23:24 Vae永Silence 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.给定一个整数n,返回n!(n的阶乘)数字中的后缀0的个数。... 阅读全文
posted @ 2015-02-08 23:22 Vae永Silence 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文
posted @ 2015-02-08 23:17 Vae永Silence 阅读(106) 评论(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-02-08 23:13 Vae永Silence 阅读(166) 评论(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-02-08 23:03 Vae永Silence 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 找到最多含有两个不同字符的子串的最长长度。例如:eoeabc,最长的是eoe为3,其他都为2.例如:string s="aqaqedadcdccd";使用一个map fmap记录每个字符出现的个数,详解在程序中注释。int lengthOfLongestSubstringTwoDistinct(st... 阅读全文
posted @ 2015-02-08 22:49 Vae永Silence 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 判断两个字符串的编辑距离是不是1.两个字符串距离是1的可能性:1)两个字符串长度相等:s="abc",t="aec";2)两个字符串长度相差1(两种情况):s="abc",t="abce";或s="abc",t="aebc";bool isOneEditDistance(string s, stri... 阅读全文
posted @ 2015-02-08 22:48 Vae永Silence 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Given a sorted integer array where the range of elements are [lower,upper] inclusive, return its missing ranges.For example, given[0, 1, 3, 50, 75],lo... 阅读全文
posted @ 2015-02-08 22:47 Vae永Silence 阅读(395) 评论(0) 推荐(0) 编辑