题目:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL...
分类:
其他好文 时间:
2015-04-12 06:32:42
阅读次数:
189
题目地址:https://leetcode.com/problems/reverse-bits/题目分析:可以4bit为单位,0翻转对应0,1翻转对应8.....15翻转对应15,将这些翻转信息保存在数组中即可以O(1)的空间复杂度换来很好的时间复杂度题目解答:public class Soluti...
分类:
其他好文 时间:
2015-04-11 17:46:15
阅读次数:
113
//push and popvar testArray = [];for(var i = 10;i>=0;i++){testArray.push(i)}console.log(testArray);testArray.reverse();console.log(testArray)for(var i...
分类:
编程语言 时间:
2015-04-11 14:29:31
阅读次数:
131
从n个数中随机选取m(m
在老师布置作业的时候就想到要用数组的一些知识:
(1) Array(包含AraayList,Hashtable等一些特殊的数组)提供了Sort方法来进行排序,但它常与Reverse方法(反转数组中元素的顺序)一起配合使用。
Sort方法,接受一个数组,将其实现升序,格式为:Array.Sort(数组)
...
Nginx是什么:官网上有这样一段话:nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server, written by Igor Sysoev(伊戈尔 塞索耶夫)选择Nginx的理由 1....
分类:
其他好文 时间:
2015-04-11 10:09:44
阅读次数:
153
网上有很多这种例子:void erase(vector &v){ for(vector::reverse_iterator ri=v.rbegin();ri!=v.rend();) { if(*ri % 2 == 0) { cout &v){ for(vector::reverse_ite...
分类:
其他好文 时间:
2015-04-10 13:00:16
阅读次数:
117
题目地址:https://leetcode.com/problems/reverse-linked-list-ii/解题思路:1.找到需要翻转的开始节点,从开始节点其依次进行翻转,注意过程中要维护三个节点,curr,curr.next,curr.next.next2.如果开始翻转节点为1,则返回翻转...
分类:
其他好文 时间:
2015-04-10 01:20:15
阅读次数:
118
题意:给定一个无符号32位整数,将其二进制形式左右反置,再以整型返回。思路:循环32轮,将n往右挤出一位就补到ans的尾巴上。 1 class Solution { 2 public: 3 uint32_t reverseBits(uint32_t n) { 4 if( !n...
分类:
其他好文 时间:
2015-04-10 01:07:34
阅读次数:
109
Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321题目很简单,先判断数字的正负,再按位倒置数字就可以了。不过要考虑int的上限。代码如下:class Solution {pub...
分类:
其他好文 时间:
2015-04-09 23:14:39
阅读次数:
110
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-09 15:16:42
阅读次数:
103