【题目】
原文:
1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one...
分类:
其他好文 时间:
2014-05-16 01:50:08
阅读次数:
311
【题目】
原文:
1.7 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
译文:
写一个函数处理一个MxN的矩阵,如果矩阵中某个元素为0,那么把它所在的行和列都置为0.
【分析】
【思路一】
遍历一次矩阵...
分类:
其他好文 时间:
2014-05-15 12:27:37
阅读次数:
293
【题目】
原文:
1.6 Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?
译文:
一张图像表示...
分类:
其他好文 时间:
2014-05-15 05:43:35
阅读次数:
240
原文:
1.5 Write a method to replace all spaces in a string with ‘%20’.
译文:
写一个函数,把字符串中所有的空格替换为%20 。...
分类:
其他好文 时间:
2014-05-14 14:09:29
阅读次数:
310
今天又个兄弟求助,数据库里一个表有数据如下:
no name
1 a
2 b
3 c
4 d
如何用一个sql显示如下结果:
ab
ac
ad
bc
bd
cd
对于这种构造数据,是分析函数的强项,下面来做个试验:
create table t (no number,name varchar(2));
insert into t va...
分类:
其他好文 时间:
2014-05-07 08:03:17
阅读次数:
447
目的:科研中,需要分析在每次迭代过程中参与计算的顶点数目,来进一步优化系统。比如,在SSSP的compute()方法最后一行,都会把当前顶点voteToHalt,即变为InActive状态。所以每次迭代完成后,所有顶点都是InActive状态。在大同步后,收到消息的顶点会被激活,变为Active状态,然后调用顶点的compute()方法。本文的目的就是统计每次迭代过程中,参与计算的顶点数目。下面附上SSSP的compute()方法:...
分类:
其他好文 时间:
2014-05-07 06:25:52
阅读次数:
415
原文:
Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)
译文:
写代码翻转一个C风格的字符串。(C风格的意思是"abcd"需要用5个字符来表示,包含末尾的 结束字符)...
分类:
其他好文 时间:
2014-05-07 05:12:34
阅读次数:
265
【题目】
Chapter 1 | Arrays and Strings
原文:
1.1 Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
译文:
实现一个算法来判断一个字符串中的字符...
分类:
其他好文 时间:
2014-05-07 04:27:41
阅读次数:
312
CareerCup
目录
Chapter 1 | Arrays and Strings
1.1 Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures?
1.2 Write co...
分类:
其他好文 时间:
2014-05-07 04:25:44
阅读次数:
320
【题目】
原文:
1.4 Write a method to decide if two strings are anagrams or not.
译文:
写一个函数判断两个字符串是否是变位词。
【分析】
变位词(anagrams)指的是组成两个单词的字符相同,但位置不同的单词。比如说, abbcd和abcdb就是一对变位词。该题目有两种思路:
【思路一】
由于变位词只是字...
分类:
其他好文 时间:
2014-05-06 23:17:56
阅读次数:
383