码迷,mamicode.com
首页 >  
搜索关键字:smallest    ( 560个结果
codeforce 124B——全排列dfs——Permutations
You are givennk-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number wa...
分类:其他好文   时间:2015-07-15 01:17:15    阅读次数:244
Project Euler:Problem 62 Cubic permutations
The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits ...
分类:其他好文   时间:2015-07-14 18:21:53    阅读次数:113
【Kth Smallest Element in a BST 】cpp
题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t...
分类:其他好文   时间:2015-07-14 15:13:55    阅读次数:98
Kth Smallest Element in a BST
class Solution {public: int kthSmallest(TreeNode* root, int k) { int num = 0; TreeNode*pNode=NULL; visit(root, k, num, pNode);...
分类:其他好文   时间:2015-07-14 15:01:24    阅读次数:82
Kth Smallest Element in a BST
该题的思路很简单,就是对BST进行先序遍历,找到第k个数的时候返回。这里借助栈用迭代实现,递归的代码更简单,没有尝试。 class Solution { public: int kthSmallest(TreeNode* root, int k) { stack cache; TreeNode *point = root; TreeNode...
分类:其他好文   时间:2015-07-12 17:27:38    阅读次数:85
Quiz 2
def make_change(amount, coins): """Return a list of coins that sum to amount, preferring the smallest coins available and placing the smallest c...
分类:其他好文   时间:2015-07-12 00:03:57    阅读次数:165
leetcode-230-Kth Smallest Element in a BST
Kth Smallest Element in a BST   Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note:  You may assume k is always valid, 1 ≤ k ≤ BST's to...
分类:其他好文   时间:2015-07-09 14:40:05    阅读次数:122
c++训练题(数字的2~6倍只改变数字的顺序)
题目:It can be seen that the number, 125874, and its double, 251748, contains exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, ...
分类:编程语言   时间:2015-07-09 13:20:06    阅读次数:158
【LeetCode】230. Kth Smallest Element in a BST (2 solutions)
Kth Smallest Element in a BSTGiven a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is alw...
分类:其他好文   时间:2015-07-08 12:24:28    阅读次数:166
Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next()...
分类:其他好文   时间:2015-07-07 22:50:37    阅读次数:208
560条   上一页 1 ... 41 42 43 44 45 ... 56 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!