描述:
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
思路:
将字符串从后向前进行相加,最后有进位的话再创造新的位数,最后将字符串反转,输出即可。...
分类:
其他好文 时间:
2015-05-15 09:06:04
阅读次数:
99
Reverse IntegerReverse digits of an integer.Example1: x = 123, return 321
Example2: x = -123, return -321这题比较容易,就是把给的一个数,反顺序输出而已。直接对10取余数,把每一位数字读出来,再生成一个新的数就可以了,边界有一个溢出的问题,在这里,我选择的方法是定义一个long类型的变量,该变量...
分类:
其他好文 时间:
2015-05-14 23:51:33
阅读次数:
161
翻转单链表(要注意的是是否含有头结点):思路一:每次将第一个节点后的那个节点放到第一个位置。若无头结点,则额外需要一个指针记录首节点。代码:/** * Definition for singly-linked list. * public class ListNode { * int val...
分类:
编程语言 时间:
2015-05-14 18:19:12
阅读次数:
218
题目描述:
Reverse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary a...
分类:
其他好文 时间:
2015-05-14 16:30:40
阅读次数:
102
一什么是ngrok ngrok is a reverse proxy that creates a secure tunnel from a public endpoint to a locally running web service. ngrok captures and analyzes ....
分类:
其他好文 时间:
2015-05-14 15:38:59
阅读次数:
134
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321考虑输入是abc,返回结果是cba,那么假设用除法(除以10)取余数操作的话,是先入先出的操作(第一次入abc%10=c),因...
分类:
其他好文 时间:
2015-05-14 13:50:40
阅读次数:
96
题目描述:
everse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as00...
分类:
其他好文 时间:
2015-05-13 22:07:09
阅读次数:
217
Reverse digits of an integer.Example1: x = 123, return 321
Example2: x = -123, return -321 click to show spoilers.Have you thought about this?
Here are some good questions to ask before coding. Bonu...
分类:
其他好文 时间:
2015-05-13 21:49:54
阅读次数:
235
一、实现功能:
将输入字符串abcde反转成edcba输出
二、代码
#include
#include
#include
#define MAX_STR 10
void reverse_string(char * string)
{
int len = strlen(string);
assert(string);
if (len <= 1)
{
return;...
分类:
其他好文 时间:
2015-05-13 16:56:32
阅读次数:
133
public class Solution { public boolean isPalindrome(int x) { if (x < 0) { return false; } return x == reverse(x); ...
分类:
其他好文 时间:
2015-05-13 12:19:59
阅读次数:
68