随笔分类 -  位运算

摘要:private static String convertBinary(int sum) { StringBuffer binary = new StringBuffer(); while (true) { binary.insert(0, sum % 2); sum = sum / 2... 阅读全文
posted @ 2017-12-03 08:53 apanda009 阅读(177) 评论(0) 推荐(0)
摘要:方法2:进一步的方法是用HashSet, 每次取长度为10的字符串,O(N)时间遍历数组,重复就加入result,但这样需要O(N)的space, 准确说来O(N*10bytes), java而言一个char是2 bytes,所以O(N*20bytes)。String一大就MLE 最优解:是在方法2 阅读全文
posted @ 2017-12-02 04:48 apanda009 阅读(183) 评论(0) 推荐(0)
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm should run i... 阅读全文
posted @ 2017-10-10 01:15 apanda009 阅读(133) 评论(0) 推荐(0)
摘要:A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents 阅读全文
posted @ 2017-07-11 17:18 apanda009 阅读(153) 评论(0) 推荐(0)