Daily Archives: September 19, 2012

for a string array, given 2 words, find min distance between them.

  the distance is measured by how many words between these 2 words:   public int shortest( String[] words, String word1, String word2 ){    if( words.length < 1 )     {         return -1     };    if( word1 == null … Continue reading

Posted in Uncategorized | Leave a comment

0-N 中 1 的个数

http://blog.csdn.net/livelylittlefish/article/details/2768348

Posted in Uncategorized | Leave a comment

整数的平均值

对于两个整数x,y,如果用 (x+y)/2 求平均值,会产生溢出,因为 x+y 可能会大于INT_MAX,但是我们知道它们的平均值是肯定不会溢出的,我们用如下算法: #define AVE(x,y) ((x)&(y))+(((x)^(y))>>1)   http://blog.csdn.net/oanqoanq/article/category/938009

Posted in Uncategorized | Leave a comment

how to do add withou using +

char *c;    c = ( char * )a;00CA144E  mov         eax,dword ptr [a] 00CA1451  mov         dword ptr [c],eax     return (int)&c[b];00CA1454  mov         eax,dword ptr [c] 00CA1457  add         eax,dword ptr [b]

Posted in Uncategorized | Leave a comment