[剑指Offer]41 和为S的两个数字 VS 和为S的连续正数序列 Leetcode T1 Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the s…
剑指 Offer 15. 二进制中1的个数 Offer 15 题目描述: 方法一:使用1逐位相与的方式来判断每位是否为1 /** * 方法一:使用1逐位与的方法 */ public class Offer_15 { // you need to treat n as an unsigned value public int hammingWeight(int n) { int sum = 0; while(n != 0){ // 这里不是n > 0作为边界条件 sum += n & 1; n…