原文链接: https://leetcode-cn.com/problems/divide-two-integers 英文原文Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. The integer division should truncate toward zero, which means losing…
标签详情
位运算 分类
原文链接: https://leetcode-cn.com/problems/add-binary 英文原文Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: 1 <= …
原文链接: https://leetcode-cn.com/problems/subsets 英文原文Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: n…
原文链接: https://leetcode-cn.com/problems/gray-code 英文原文An n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n - 1], The first integer is 0, An integer appears no more than once in the sequence, Th…
原文链接: https://leetcode-cn.com/problems/subsets-ii 英文原文Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example…
原文链接: https://leetcode-cn.com/problems/single-number 英文原文Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant …
原文链接: https://leetcode-cn.com/problems/repeated-dna-sequences 英文原文The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGAATTCCG" is a DNA sequence. When studying DNA, it is useful to identify …
原文链接: https://leetcode-cn.com/problems/reverse-bits 英文原文Reverse bits of a given 32 bits unsigned integer. Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signe…
原文链接: https://leetcode-cn.com/problems/number-of-1-bits 英文原文Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages, such as Java, there is no uns…
原文链接: https://leetcode-cn.com/problems/bitwise-and-of-numbers-range 英文原文Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive. Example 1: Input: left = 5, right = 7 Ou…
原文链接: https://leetcode-cn.com/problems/power-of-two 英文原文Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2x. Example 1: Input: n = 1 Output: …
原文链接: https://leetcode-cn.com/problems/single-number-iii 英文原文Given an integer array 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. You can return the …
原文链接: https://leetcode-cn.com/problems/missing-number 英文原文Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanatio…
原文链接: https://leetcode-cn.com/problems/find-the-duplicate-number 英文原文Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number…
原文链接: https://leetcode-cn.com/problems/maximum-product-of-word-lengths 英文原文Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such two words exist, return 0…
原文链接: https://leetcode-cn.com/problems/counting-bits 英文原文Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i. Example 1: Input: n = 2 Output: [0,1,1…
原文链接: https://leetcode-cn.com/problems/power-of-four 英文原文Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4x. Example 1: Input: n = 16 Outp…
原文链接: https://leetcode-cn.com/problems/sum-of-two-integers 英文原文Given two integers a and b, return the sum of the two integers without using the operators + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = 2, b = 3 Output: 5 Const…
原文链接: https://leetcode-cn.com/problems/find-the-difference 英文原文You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t. Example 1: …
原文链接: https://leetcode-cn.com/problems/utf-8-validation 英文原文Given an integer array data representing the data, return whether it is a valid UTF-8 encoding. A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: For a 1-b…
原文链接: https://leetcode-cn.com/problems/integer-replacement 英文原文Given a positive integer n, you can apply one of the following operations: If n is even, replace n with n / 2. If n is odd, replace n with either n + 1 or n - 1. Return the minimum number…
原文链接: https://leetcode-cn.com/problems/convert-a-number-to-hexadecimal 英文原文Given an integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used. All the letters in the answer …
原文链接: https://leetcode-cn.com/problems/binary-watch 英文原文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 a zero or one, with the least significant bi…
原文链接: https://leetcode-cn.com/problems/maximum-xor-of-two-numbers-in-an-array 英文原文Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n. Example 1: Input: nums = [3,10,5,25,2,8] Output: 28 Explanation: T…
原文链接: https://leetcode-cn.com/problems/hamming-distance 英文原文The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, return the Hamming distance between them. Exam…
原文链接: https://leetcode-cn.com/problems/can-i-win 英文原文In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10. The player who first causes the running total to reach or exceed 100 wins. What if we change the game …
原文链接: https://leetcode-cn.com/problems/matchsticks-to-square 英文原文You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any sti…
原文链接: https://leetcode-cn.com/problems/number-complement 英文原文The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. For example, The integer 5 is "101" in binary and i…
原文链接: https://leetcode-cn.com/problems/total-hamming-distance 英文原文The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given an integer array nums, return the sum of Hamming distances bet…
原文链接: https://leetcode-cn.com/problems/increasing-subsequences 英文原文Given an integer array nums, return all the different possible increasing subsequences of the given array with at least two elements. You may return the answer in any order. The given…
1 / 5