要搜索的对象是一个rotated sorted array,所以从直觉上时间复杂度应该不会超过O(logn)。起初我想尝试修改binary search来解决这个问题,但仔细思考后发现在不断search的过程中,search的boundary是比较难确定的。解决这个题目的另一个思路就是先把pivot...
分类:
其他好文 时间:
2014-08-02 15:21:23
阅读次数:
359
#include#include#includechar *g_WordTable[10]= {"zero", "one", "two", "three", "four", "five","six", "seven", "eight", "nine"};int main(){ //存放用户输入...
分类:
其他好文 时间:
2014-08-02 12:31:53
阅读次数:
530
Suppose we have a framefinal JFrame jframe = new JFrame("Triangle 3");To catch window closing events and quit, there are two ways (as I know):Way1.jfr...
问题描述:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->...
分类:
其他好文 时间:
2014-08-02 01:33:12
阅读次数:
249
Edit DistanceGiven two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You...
分类:
其他好文 时间:
2014-08-02 01:29:22
阅读次数:
309
问题:将B按顺序合并到A上分析:插入排序,注意A数组为空class Solution{public: void merge(int A[], int m, int B[], int n) { int i,j; if(m==0) { ...
分类:
其他好文 时间:
2014-08-01 22:54:32
阅读次数:
184
In this challenge you need to print the data that accompanies each integer in a list. In addition, if two strings have the same integers, you need to ...
分类:
其他好文 时间:
2014-08-01 22:40:42
阅读次数:
323
Problem Description:
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
分析:两个string相乘...
分类:
其他好文 时间:
2014-08-01 16:06:01
阅读次数:
141
问题描述:
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
解题思路:...
分类:
其他好文 时间:
2014-08-01 13:48:11
阅读次数:
183
Mobile phoneshttp://poj.org/problem?id=1195 1 #include 2 #include 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 const int M=1030; 5 class Two_Tree_Array {...
分类:
其他好文 时间:
2014-08-01 13:03:01
阅读次数:
168