Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
#include
int reverse(int x)
{
long long tmp1=(long long)x;
long long tmp2=(long long)x;
...
分类:
其他好文 时间:
2014-11-23 18:59:33
阅读次数:
188
源于hdu1013题目描述:The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that...
分类:
其他好文 时间:
2014-11-23 18:54:41
阅读次数:
249
Integer to Roman Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.SOLUTION 1: 1 package Algor...
分类:
其他好文 时间:
2014-11-23 17:26:35
阅读次数:
173
given an integer ,find 最小长度minlen 的expression of integer, minlen 定义为多少个完全平方数相加例如 14 = 1 + 4 + 9, minlen = 3int MinExpressionInteger(int i){ int k =...
分类:
其他好文 时间:
2014-11-23 17:15:54
阅读次数:
189
问题描述:
Given an unsorted integer array, find the first missing positive integer.
For example,
Given [1,2,0] return 3,
and [3,4,-1,1] return 2.
Your algorithm should run in O(n) time and uses con...
分类:
其他好文 时间:
2014-11-23 16:02:15
阅读次数:
211
int atoi(const char *str) { long long result = 0; while (*str==' ')str++; int flag=0; if (*str == '-' || *str == '+') { flag = (*str == '-') ? -1 : 1....
分类:
其他好文 时间:
2014-11-23 15:47:53
阅读次数:
166
Determine whether an integer is a palindrome. Do this without extra space.因为都额外空间有限制所以不能把他先转成字符串然后用两个指针扫了。负数不算回文数是因为前面多了个负号么=_= 这样的话我只能想到一个办法,就是反转一个数字...
分类:
其他好文 时间:
2014-11-23 11:38:33
阅读次数:
176
Problem Description
Alexandra has a little brother. He is new to programming. One day he is solving the following problem: Given an positive integer N, judge whether N is prime.
The problem above is...
分类:
其他好文 时间:
2014-11-23 09:26:35
阅读次数:
240
Problem Description
A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the ...
分类:
其他好文 时间:
2014-11-23 00:44:31
阅读次数:
244
Problem Description
A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbe...
分类:
其他好文 时间:
2014-11-22 21:36:21
阅读次数:
212