随笔分类 -  Bit Manipulation & Precision Operation

摘要:[抄题]: Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary represen 阅读全文
posted @ 2018-08-04 20:56 苗妙苗 阅读(208) 评论(0) 推荐(0)
摘要:[抄题]: According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician 阅读全文
posted @ 2018-08-02 09:46 苗妙苗 阅读(199) 评论(0) 推荐(0)
摘要:[抄题]: The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the tot 阅读全文
posted @ 2018-07-30 10:36 苗妙苗 阅读(124) 评论(0) 推荐(0)
摘要:[抄题]: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Now your job is to find the 阅读全文
posted @ 2018-05-15 11:41 苗妙苗 阅读(229) 评论(0) 推荐(0)
摘要:[抄题]: Reverse bits of a given 32 bits unsigned integer. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: [一句话思路]: 32 阅读全文
posted @ 2018-05-04 11:38 苗妙苗 阅读(164) 评论(0) 推荐(0)
摘要:[抄题]: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 阅读全文
posted @ 2018-05-04 11:14 苗妙苗 阅读(238) 评论(0) 推荐(0)
摘要:[抄题]: Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear 阅读全文
posted @ 2018-04-24 16:35 苗妙苗 阅读(430) 评论(0) 推荐(0)
摘要:[抄题]: Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 3 阅读全文
posted @ 2018-03-13 22:16 苗妙苗 阅读(127) 评论(0) 推荐(0)
摘要:[抄题]: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, 阅读全文
posted @ 2018-03-13 21:48 苗妙苗 阅读(243) 评论(0) 推荐(0)
摘要:[抄题]: Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime c 阅读全文
posted @ 2018-03-13 21:38 苗妙苗 阅读(139) 评论(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 repre 阅读全文
posted @ 2018-03-09 10:03 苗妙苗 阅读(211) 评论(0) 推荐(0)
摘要:[抄题]: 以字符串的形式给定两个非负整数 num1 和 num2,返回 num1 和 num2 的乘积。 [暴力解法]: 时间分析: 空间分析: [思维问题]: 还要找到结果中第一位不等于0的数再添加,没想到 [一句话思路]: 套公式, 没有carry进位了,全都是对ans直接进行操作: ans[ 阅读全文
posted @ 2018-02-23 20:59 苗妙苗 阅读(251) 评论(0) 推荐(0)
摘要:反向存储,从左往右加 [抄题]: 你有两个用链表代表的整数,其中每个节点包含一个数字。数字存储按照在原来整数中相反的顺序,使得第一个数字位于链表的开头。写出一个函数将两个整数相加,用链表形式返回和。给出两个链表 3->1->5->null 和 5->9->2->null,返回 8->0->8->nu 阅读全文
posted @ 2018-02-23 19:22 苗妙苗 阅读(233) 评论(0) 推荐(0)
摘要:[抄题]: 以字符串的形式给出两个非负整数 num1 和 num2,返回 num1和 num2 的和。 比如一个50位+一个100位。 给定 num1 = "123",num2 = "45" 返回 "168" [暴力解法]: 时间分析: 空间分析: [思维问题]: [一句话思路]: [输入量]:空: 阅读全文
posted @ 2018-02-23 11:28 苗妙苗 阅读(245) 评论(0) 推荐(0)