码迷,mamicode.com
首页 >  
搜索关键字:reverse    ( 5099个结果
Rotate Array
class Solution {public: void rotate(int nums[], int n, int k) { k%=n; reverse(nums,0,n-k-1); reverse(nums,n-k,n-1); rev...
分类:其他好文   时间:2015-04-30 23:07:39    阅读次数:143
OJ练习37——T190 Reverse Bits
把一个32位无符号整数按位翻转,For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary...
分类:其他好文   时间:2015-04-30 10:13:02    阅读次数:128
9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.类似于reverse integer。public class Solution { public boolean isPalindrome(...
分类:其他好文   时间:2015-04-30 07:36:35    阅读次数:119
7. Reverse Integer
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321注意溢出,溢出返回0public class Solution { public int reverse(int x...
分类:其他好文   时间:2015-04-30 07:33:24    阅读次数:99
秒懂单链表及其反转(reverse)
什么是链表,这种数据结构是由一组Node组成的,这群Node一起表示了一个序列。链表是最普通,最简单的数据结构,它是实现其他数据结构如stack, queue等的基础。 链表比起数组来,更易于插入,删除。 Node可以定义如下: typedef int element_type; typedef struct node *node_ptr; struct node { el...
分类:其他好文   时间:2015-04-29 23:27:55    阅读次数:192
【LeetCode】007 Reverse Interger
题目:LeetCode 007 Reverse Interger题意:将一个整数的数字反转。保留正负符号。思路:先将整数变成字符串,然后判断是否为负数,或是否含有’+’,然后从字符串末尾开始累计得到新整数即可。但是还会有特殊情况,即正向为Int范围内,但反转之后会溢出,因此要进行特判。代码如下: 1...
分类:其他好文   时间:2015-04-29 21:32:57    阅读次数:137
[LeetCode]-007-Reverse Integer
网址:https://leetcode.com/problems/reverse-integer/ 题意: 反转数字,正负不变. 分析: 思路显而易见, 重点在有些刁钻的输入输出上. 解法: 因为无视正负,又要用到mod. 自然想到abs... 不过abs对于int并不完全适用. 使用前,判断一下是不是INT_MIN或Integer.MIN_VALUE 我又不想记住这个正负,...
分类:其他好文   时间:2015-04-29 19:49:22    阅读次数:129
编程之美学习笔记之 一摞烙饼的排序
编程之美书中讲的一摞烙饼的排序一题 这里无法用基本的排序方法对其排序,那么最直接的方法是找出N个数种最大者,将这通过两次翻转放置到最底部,然后处理N-1,N-2等,直到全部排序完,所以一共需要交换2(N-1)次void reverse(int cakes[], int beg, int end) { int temp; while(beg < end){ temp...
分类:编程语言   时间:2015-04-29 17:14:49    阅读次数:151
LeetCode(2)-- Add Two Numbers
Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes co...
分类:其他好文   时间:2015-04-29 13:17:19    阅读次数:122
2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ...
分类:其他好文   时间:2015-04-29 13:08:35    阅读次数:113
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!