06 2018 档案

摘要:leetcode中一个题目,让统计二进制中1的个数。首先第一个想法便是用位运算一位一位的去判断,这样便可以了,但是题目却有个要求复杂度小于 O(n*sizeof(integer))。 这样便无法按着integer的size去逐个计算。 n&(n-1)每次计算都会将最末尾的1去掉这样就可以更快的计算出 阅读全文
posted @ 2018-06-07 21:12 Mr.Struggle 阅读(816) 评论(0) 推荐(0)
摘要:344. Reverse String Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". 一开始写了一个代 阅读全文
posted @ 2018-06-04 22:27 Mr.Struggle 阅读(598) 评论(0) 推荐(0)