2014年10月7日

Rand1 -> RandN

摘要: Rand1*1 => uinformly distribution of 0,1 2Rand1*2 + Rand1 => 0,1,2,3 4Rand1*3 + Rand2 => 0,1,2,3,4,5 6Rand1*4 + Rand3 => 0,1,... 阅读全文

posted @ 2014-10-07 06:12 brave_bo 阅读(393) 评论(0) 推荐(0)

rand(5) -> rand(7)

摘要: int rand7() //random number from 1 - 7{ int r = 0; do { int a = rand(5) - 1; //uniformly at random from 0 to 4 int b = rand(5) - ... 阅读全文

posted @ 2014-10-07 05:40 brave_bo 阅读(354) 评论(0) 推荐(0)

神小逻辑 Remove Duplicates from Sorted Array

摘要: /*put all vaild new array from the 0 to new length*/public class Solution { public int removeDuplicates(int[] A) { if(A.length < 2) ... 阅读全文

posted @ 2014-10-07 04:19 brave_bo 阅读(111) 评论(0) 推荐(0)

基础 sorted array查找最多的一个值.

摘要: int pp = 1; //number of points in the same line of the point i if (k.size()==0){pp=0;} for (int jj=1;jjres){res=pp... 阅读全文

posted @ 2014-10-07 03:07 brave_bo 阅读(171) 评论(0) 推荐(0)

Max Points on a Line

摘要: 计算所有的slope 放到一个arraylist中. 特殊情况是the same as point . 遍历所有./** * Definition for a point. * struct Point { * int x; * int y; * Point() : x(0)... 阅读全文

posted @ 2014-10-07 03:05 brave_bo 阅读(149) 评论(0) 推荐(0)

导航