随笔分类 -  leetcode_bit

摘要:Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Example 1: Example 2: 阅读全文
posted @ 2017-10-25 20:26 daniel456 阅读(208) 评论(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 total 阅读全文
posted @ 2017-10-25 12:11 daniel456 阅读(156) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum result of ai XOR aj, where 0 ≤ i, j < n. Could you do t 阅读全文
posted @ 2017-10-25 12:10 daniel456 阅读(121) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer n and you can do operations as follow: What is the minimum number of replacements needed for n to become 1? 含义:给定一个正数n,如果n是偶数 阅读全文
posted @ 2017-10-25 12:05 daniel456 阅读(131) 评论(0) 推荐(0) 编辑
摘要:Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assum 阅读全文
posted @ 2017-10-25 11:55 daniel456 阅读(93) 评论(0) 推荐(0) 编辑
摘要:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements 阅读全文
posted @ 2017-10-25 11:44 daniel456 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5, 阅读全文
posted @ 2017-10-25 11:24 daniel456 阅读(101) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note:Your algorithm sh 阅读全文
posted @ 2017-10-25 11:12 daniel456 阅读(94) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 1: Exa 阅读全文
posted @ 2017-10-25 11:06 daniel456 阅读(122) 评论(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, calcul 阅读全文
posted @ 2017-10-25 11:04 daniel456 阅读(116) 评论(0) 推荐(0) 编辑
摘要:Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: Example 1: Example 2: 阅读全文
posted @ 2017-10-25 11:02 daniel456 阅读(114) 评论(0) 推荐(0) 编辑
摘要:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example:Given a = 1 and b = 2, return 3. 含义:不用加减运算符,计算 阅读全文
posted @ 2017-10-25 10:55 daniel456 阅读(76) 评论(0) 推荐(0) 编辑
摘要:Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Given num = 16, return true. Given num = 5, return fa 阅读全文
posted @ 2017-10-25 10:52 daniel456 阅读(104) 评论(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 32-bit 阅读全文
posted @ 2017-10-25 10:31 daniel456 阅读(88) 评论(0) 推荐(0) 编辑
摘要:Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur 阅读全文
posted @ 2017-10-25 10:30 daniel456 阅读(82) 评论(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-10-24 20:19 daniel456 阅读(91) 评论(0) 推荐(0) 编辑
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to 阅读全文
posted @ 2017-10-24 11:24 daniel456 阅读(337) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, every element appears twice except for one. Find that single one. 题目含义:给定的数组中,每个数字出现两次,只有一个数字出现了一次,找出这个数字 阅读全文
posted @ 2017-10-23 21:21 daniel456 阅读(95) 评论(0) 推荐(0) 编辑
摘要:Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at 阅读全文
posted @ 2017-10-23 20:52 daniel456 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Given an integer, write a function to determine if it is a power of two. 题目含义:判断一个数是否是2的n次方 阅读全文
posted @ 2017-10-20 20:28 daniel456 阅读(120) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示