题意:由01两个数字组成的十进制数,加起来等于n,求最少有多少个这样的数字
分析:灵活创新,思维转换;如:415=111+101+101+101+1,不用想什么十进制减法什么的
代码:
#include
using namespace std;
int main()
{
char a[10];
int i=0,hight=0;
while(cin>>a[i]) i++;
for(in...
分类:
其他好文 时间:
2015-07-12 00:22:19
阅读次数:
288
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two...
分类:
其他好文 时间:
2015-07-11 22:56:23
阅读次数:
386
Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre...
分类:
其他好文 时间:
2015-07-11 22:49:47
阅读次数:
110
The problem becomes more difficult once the binary tree is not perfect. The idea is still similar to use a level-order traversal. Note that we do not ...
分类:
其他好文 时间:
2015-07-11 20:02:27
阅读次数:
132
A simple application of level-order traversal. Just push the last node in each level into the result.The code is as follows. 1 class Solution { 2 publ...
分类:
其他好文 时间:
2015-07-11 20:01:41
阅读次数:
107
Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa...
分类:
其他好文 时间:
2015-07-11 19:55:47
阅读次数:
177
Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.Ac...
分类:
其他好文 时间:
2015-07-11 18:21:07
阅读次数:
121
Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.Ac...
分类:
其他好文 时间:
2015-07-11 18:03:46
阅读次数:
137
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined
betw...
分类:
其他好文 时间:
2015-07-11 16:51:07
阅读次数:
126
https://leetcode.com/submissions/detail/32662938/Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST...
分类:
其他好文 时间:
2015-07-11 16:19:19
阅读次数:
98