码迷,mamicode.com
首页 >  
搜索关键字:leetcode happy numbe    ( 36157个结果
LeetCode OJ - Linked List Cycle II
题目: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you solve it without using extr...
分类:其他好文   时间:2014-05-16 04:50:13    阅读次数:329
Leetcode 二分查找 Search a 2D Matrix
题意:在一个二维矩阵中找到给定的值。矩阵从上到下从左到右有序 思路:二维空间的二分查找 先在一维里找中间位置,再将该位置转为二维空间里的下标 注:下标比较难弄,得注意点 复杂度: 时间O(log n),空间O(1) 相关题目: Search Insert Position...
分类:其他好文   时间:2014-05-15 07:24:42    阅读次数:253
Leetcode 线性表 Remove Duplicates from Sorted Array
题意:从一个已排序的数组中移除掉重复的元素 思路:用下标i扫描旧数组,用下标j来保存新数组的尾部 如果旧数组的当前元素与新数组的最后一个元素相同,则继续扫描旧数组 如果不同,新数组的下标前移一们,将旧数组的当前元素赋给新数组,继续扫描旧数组 相关题目: Remove Element Remove Duplicates from Sorted List Remove Duplicates from Sorted List II...
分类:其他好文   时间:2014-05-15 06:57:53    阅读次数:249
Leetcode 线性表 Remove Duplicates from Sorted List
题意:去掉已排序的链表里重复的元素 思路: 1.遍历链表,用一个变量保存当前链表节点的值 2.如果当前链表节点值与前面的一样,则删除当前链表节点 3.否则用当前节点值更新该变量 复杂度:时间O(n), 空间O(1)...
分类:其他好文   时间:2014-05-15 06:46:24    阅读次数:218
leetCode解题报告5道题(七)
5道题目分别是:【Interleaving String】、【Validate Binary Search Tree】、【Sqrt(x) 】、【Recover Binary Search Tree 】、【Climbing Stairs 】,由于有一些题目不需要发一整篇博文来记录,所以就将这些题目以一篇博文5道来记录。...
分类:其他好文   时间:2014-05-15 06:30:55    阅读次数:301
LeetCode 006 ZigZag Conversion
【题目】 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSI...
分类:其他好文   时间:2014-05-15 04:30:57    阅读次数:313
【LeetCode】Plus One
题目 Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 解答 本题考察进位问题,注...
分类:其他好文   时间:2014-05-15 04:16:56    阅读次数:245
LeetCode Sort List
在 O(nlogn)的时间内对一个链表进行排序。。明显是要用归并或者快排 第一次知道说原来归并也可以用链表来写,被刷了下三观。。。。。用快慢指针的方法找分界点。 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNod...
分类:其他好文   时间:2014-05-14 15:03:49    阅读次数:230
Leetcode: Trapping Rain Water
这道题做的比较艰辛,一开始自己想的是一个用stack的解法,感觉过于繁琐(出栈,入栈,计算容积),但未尝不是一个好的尝试,这个方法还是有点小问题,过后会好好想清楚。看了网上提示完成了最终的方法,这个方法两次遍历数组,第一次遍历找每个元素右边最大的元素,第二次遍历寻找每个元素左边最大的元素,同时计算该...
分类:移动开发   时间:2014-05-14 11:03:34    阅读次数:412
Leetcode: Unique Paths
这道题最开始采用recursive的方法,结果犯了TLE(time limit exceeded)的错误,事实证明recursive的时间代价还是太高,所以改用DP的方法,把曾经算出来的结果存起来,我用的是一个M*N的matrix来存储 1 public class Solution { 2 ...
分类:其他好文   时间:2014-05-14 10:57:31    阅读次数:245
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!