
Bit Manipulation
WX_ming
写代码就像写作文一样,思路要明确,方法要对,否则又臭又长还出错
展开
-
[WXM] LeetCode 318. Maximum Product of Word Lengths C++
318. Maximum Product of Word LengthsGiven 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 assume that each ...原创 2018-09-04 15:07:10 · 300 阅读 · 0 评论 -
[WXM] LeetCode 201. Bitwise AND of Numbers Range C++
201. Bitwise AND of Numbers RangeGiven a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.Example 1:Input: [5,7]Output: 4...原创 2018-09-04 16:02:08 · 240 阅读 · 0 评论 -
[WXM] LeetCode 397. Integer Replacement C++
397. Integer ReplacementGiven a positive integer n and you can do operations as follow:1.If n is even, replace n with n/2. 2.If n is odd, you can replace n with either n + 1 or n - 1. What is th...原创 2018-09-04 17:13:57 · 268 阅读 · 0 评论 -
[WXM] LeetCode 137. Single Number II C++
137. Single Number IIGiven a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a lin...原创 2018-09-02 21:37:21 · 246 阅读 · 0 评论 -
[WXM] LeetCode 898. Bitwise ORs of Subarrays C++
898. Bitwise ORs of SubarraysWe have an array A of non-negative integers.For every (contiguous) subarray B = [A[i], A[i+1], …, A[j]] (with i <= j), we take the bitwise OR of all the elements in...原创 2018-09-02 22:19:31 · 699 阅读 · 0 评论 -
[WXM] LeetCode 260. Single Number III C++
260. Single Number IIIGiven 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 that appear only once.Ex...原创 2018-09-03 08:11:41 · 245 阅读 · 0 评论 -
[WXM] LeetCode 421. Maximum XOR of Two Numbers in an Array C++
421. Maximum XOR of Two Numbers in an ArrayGiven 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 d...原创 2018-09-03 09:53:56 · 219 阅读 · 0 评论