码迷,mamicode.com
首页 >  
搜索关键字:leetcode happy numbe    ( 36157个结果
LeetCode --- Plus One
题目链接题意:给出一个以数组形式表示的数, 求该数加1后的结果,同样以数组形式返回。附上代码: 1 class Solution { 2 public: 3 vector plusOne(vector &digits) { 4 unsigned int len = digit...
分类:其他好文   时间:2014-05-12 12:49:34    阅读次数:268
[leetcode]Binary Tree Preorder Traversal @ Python
原题地址:http://oj.leetcode.com/problems/binary-tree-preorder-traversal/题意:这题用递归比较简单。应该考察的是使用非递归实现二叉树的先序遍历。解题思路:使用一个栈。先遍历节点,然后将这个节点入栈,如果这个节点的左孩子非空,遍历左孩子,然...
分类:编程语言   时间:2014-05-12 12:09:39    阅读次数:327
Leetcode | Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:其他好文   时间:2014-05-12 10:11:40    阅读次数:276
LeetCode Maximal Rectangle
class Solution {public: int maximalRectangle(vector > &matrix) { int rows = matrix.size(); if (rows == 0) return 0; int cols =...
分类:其他好文   时间:2014-05-12 09:54:05    阅读次数:250
Leetcode | Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from th...
分类:其他好文   时间:2014-05-12 09:37:51    阅读次数:287
【LeetCode】Set Matrix Zeroes
Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A s...
分类:其他好文   时间:2014-05-12 08:22:51    阅读次数:255
[leetcode]Binary Tree Postorder Traversal @ Python
原题地址:http://oj.leetcode.com/problems/binary-tree-postorder-traversal/题意:实现后序遍历。递归实现比较简单,非递归实现。解题思路:这道题的迭代求解比先序遍历和后序遍历要麻烦一些。假设一棵树是这样的: ...
分类:编程语言   时间:2014-05-12 08:13:39    阅读次数:336
【LeetCode】Search in Rotated Sorted Array
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).You are given a target value t...
分类:其他好文   时间:2014-05-12 07:31:40    阅读次数:332
LeetCode Insertion Sort List
class Solution {public: ListNode *insertionSortList(ListNode *head) { if (head == NULL) return NULL; ListNode* sorted_head = head; ...
分类:其他好文   时间:2014-05-10 20:39:14    阅读次数:419
【LeetCode】Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.public class Solution { public String int...
分类:其他好文   时间:2014-05-10 20:31:10    阅读次数:335
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!