码迷,mamicode.com
首页 >  
搜索关键字:leetcode 19    ( 34993个结果
LeetCode Simplify Path
class Solution {public: string simplifyPath(string path) { int len = path.length(); if (len spath; int p = -1, q = 0; ...
分类:其他好文   时间:2014-06-04 20:15:49    阅读次数:197
[leetcode]Median of Two Sorted Arrays @ Python
原题地址:https://oj.leetcode.com/problems/median-of-two-sorted-arrays/题意:There are two sorted arrays A and B of size m and n respectively. Find the median...
分类:编程语言   时间:2014-06-04 18:52:31    阅读次数:356
LeetCode Merge K Sorted Lists
class Solution {public: ListNode *mergeKLists(vector &lists) { ListNode* merged = NULL; for (int i=0; ival val) { n...
分类:其他好文   时间:2014-06-03 13:26:43    阅读次数:219
LeetCode: Sort Colors 题解
Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh...
分类:其他好文   时间:2014-06-03 13:13:50    阅读次数:537
LeetCode Merge Sorted Array
class Solution {public: void merge(int A[], int m, int B[], int n) { int mi = m + n - 1; int ai = m - 1; int bi = n - 1; ...
分类:其他好文   时间:2014-06-03 12:57:28    阅读次数:217
LeetCode Merge Intervals
class Solution {private: static int compare(const Interval& a, const Interval& b) { return a.start merge(vector &intervals) { vector...
分类:其他好文   时间:2014-06-03 12:32:23    阅读次数:228
LeetCode: Roman to Interger 题解
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.找到规则即可罗马数字的表示:I~1 V~5 X~10 L~50 C~100 D~500 ...
分类:其他好文   时间:2014-06-03 12:09:16    阅读次数:210
LeetCode --- Valid Palindrome
题目链接判断字符串是否为回文串。附上代码: 1 class Solution { 2 public: 3 bool isPalindrome(string s) { 4 if (s.empty()) return true; // consider empty string ...
分类:其他好文   时间:2014-05-30 21:48:12    阅读次数:347
[leetcode]_Container With Most Water
题目:在二维坐标系下,有很多个挡板,有两个挡板之间能够积蓄的水的最大面积。如下图所示:思路:我只想到暴力解法,用O(n2)的时间复杂度算出任意两个挡板形成的面积,这必须的过不了。优化解法:O(n).用两个指针 i 和 j 指向整个height[]数组的头尾。if i 指向的高度 决定,因此不会比现在...
分类:其他好文   时间:2014-05-29 17:40:09    阅读次数:312
LeetCode Permutation Sequence
class Solution {public: string getPermutation(int n, int k) { k--; if (n nums(n, 0); long seg = 1; for (int i=0; i= se...
分类:其他好文   时间:2014-05-29 17:04:51    阅读次数:209
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!