std::fill 在[first, last)范围内填充值#include #include
#include int main(){ std::vector v; v.resize(10); std::fill(v.begin(), v.end(),
100); retu...
分类:
编程语言 时间:
2014-05-24 05:15:36
阅读次数:
320
MSS(Array[],N)//Where N is the number of
elements in array{sum=0; //current summax-sum=0;//Maximum Sumseq-start=0;//start
of the subsequenceseq-end=0;...
分类:
其他好文 时间:
2014-05-23 11:03:58
阅读次数:
221
题目总结:
1.若没有进行旋转,或者说旋转后的效果跟没有旋转是一样的,那么index1指示的值小于index2指示的值,返回index1的值。
2.若是一般性的旋转,那么最小的值旋转后肯定在中间,那么我们就可以从两边向中间夹逼。
3.夹逼的过程中,若 [ index1, middle ] 是有序的,说明这部分子区间没被破坏,旋转所移动的元素都在middle 的后面,那么最小值可定也在后面的部...
分类:
其他好文 时间:
2014-05-22 13:42:45
阅读次数:
236
【题目】
原文:
2.2 Implement an algorithm to find the nth to last element of a singly linked list.
译文:
实现一个算法从一个单链表中返回倒数第n个元素。
【分析】
【思路一】
(1)创建两个指针p1和p2,指向单链表的开始节点。
(2)使p2移动n-1个位置,使之指向从头...
分类:
其他好文 时间:
2014-05-22 09:03:53
阅读次数:
315
【题目】
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is not found in the array, return [-1, -1].
For example,
Given [5...
分类:
其他好文 时间:
2014-05-22 06:44:39
阅读次数:
265
题目:不用乘、除、取模运算来实现除法。
减法可以实现除法在是我们早就知道的,但是可能会出现问题,比如极端情况,a = 0x7FFFFFFF,b = 1,求a/b,这要减法运算多少次?
回想下我们开始学习计算机的时候,涉及到的进制之间的转换,就是给定你一个十进制数,写出他的二进制,刚开始的时候很傻,就按着书上的方法去不停的除以2,除以2,除以2,。。。可笑的是居然天真的算过1024的二进制,更可...
分类:
其他好文 时间:
2014-05-21 08:32:30
阅读次数:
191
Tour
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 3470
Accepted: 1545
Description
John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a...
分类:
其他好文 时间:
2014-05-21 08:24:18
阅读次数:
354
题目:
Given an array of integers, every element appears
three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implem...
分类:
其他好文 时间:
2014-05-20 16:22:52
阅读次数:
241
Binary Tree Level Order Traversal
Total Accepted: 12441 Total
Submissions: 40879My Submissions
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left t...
分类:
其他好文 时间:
2014-05-18 10:11:13
阅读次数:
337
公司的apc smart UPS安装有管理卡(似乎是AP-9631),服务器环境有FreeBSD、Windows Server、Linux(CentOS、Ubuntu)
实际使用中有如下问题需要注意:
1、一旦安装有管理卡,UPS上自带的串口是不能再使用的
2、因为是smart UPS,apcupsd在关闭服务器之后会调用重启ups指令,这就会有如下一些问题
a、如果apcups...
分类:
其他好文 时间:
2014-05-18 06:43:01
阅读次数:
277