题目: Given an array of integers, find two numbers
such that they add up to a specific target number. The function twoSum should
return indices of the t...
分类:
其他好文 时间:
2014-04-30 03:20:07
阅读次数:
502
The gray code is a binary numeral system where
two successive values differ in only one bit.Given a non-negative
integernrepresenting the total number...
分类:
其他好文 时间:
2014-04-30 00:21:32
阅读次数:
536
1. Modulus operator (%)The modulus operator
works on integers and yields the remainder when the first operand is divided by
the second. In Python, the...
分类:
其他好文 时间:
2014-04-29 22:00:56
阅读次数:
495
DescriptionLetxandybe two strings over some finite
alphabetA. We would like to transformxintoyallowing only operations given
below:Deletion:a letter i...
分类:
其他好文 时间:
2014-04-29 16:22:00
阅读次数:
450
2014-04-29
00:04题目:给定一个整数数组,找出所有加起来为指定和的数对。解法1:可以用哈希表保存数组元素,做到O(n)时间的算法。代码: 1 // 17.12
Given an array of integers and target value, find all pairs in ...
分类:
其他好文 时间:
2014-04-29 15:08:13
阅读次数:
469
Binary String Matching时间限制:3000ms |
内存限制:65535KB难度:3描述Given two strings A and B, whose alphabet consist only ‘0’ and
‘1’. Your task is only to tell ho...
分类:
其他好文 时间:
2014-04-29 15:02:00
阅读次数:
564
2014-04-29
00:56题目:不用算数运算,完成加法。解法:那就位运算吧,用加法器的做法就可以了。代码: 1 // 18.1 add two numbers wihout
using arithmetic operator. 2 #include 3 using namespace std....
分类:
其他好文 时间:
2014-04-29 14:58:53
阅读次数:
383
2014-04-29
01:02题目:从m个整数里随机选出n个整数,要求等概率。解法:和洗牌的算法类似,每次随机抽出一个数,抽n次即可。时间复杂度O(m *
n),空间复杂度O(m)。代码: 1 // 18.3 pick m integers randomly from an array of n ...
分类:
其他好文 时间:
2014-04-29 14:42:32
阅读次数:
345
Jump GameGiven an array of non-negative
integers, you are initially positioned at the first index of the array.Each
element in the array represents yo...
分类:
其他好文 时间:
2014-04-28 11:30:27
阅读次数:
551
description:given two sorted singly list, merge
them into one using constant additional spacealgorithm:we will reference the two
linked list as list1 ...
分类:
其他好文 时间:
2014-04-28 00:32:52
阅读次数:
711