码迷,mamicode.com
首页 >  
搜索关键字:leetcode happy numbe    ( 36157个结果
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 ClimbingStairs
class Solution {public: int climbStairs(int n) { if (n < 1) return 0; int a = 0; int b = 1; for (int i=0; i<n; i++) { ...
分类:其他好文   时间:2014-05-29 20:23:07    阅读次数:339
[leetcode]Subsets II @ Python
原题地址:https://oj.leetcode.com/problems/subsets-ii/题意:Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:E...
分类:编程语言   时间:2014-05-29 19:10:53    阅读次数:278
[leetcode]Palindrome Partitioning @ Python
原题地址:https://oj.leetcode.com/problems/palindrome-partitioning/题意:Given a strings, partitionssuch that every substring of the partition is a palindrome...
分类:编程语言   时间:2014-05-29 18:26:15    阅读次数:334
[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
迷上了代码!