原文链接: https://leetcode-cn.com/problems/beautiful-arrangement 英文原文Suppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every i (1 <= i <= n), either of the fol…
标签详情
位运算 分类
原文链接: https://leetcode-cn.com/problems/shopping-offers 英文原文In LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale p…
原文链接: https://leetcode-cn.com/problems/set-mismatch 英文原文You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which …
原文链接: https://leetcode-cn.com/problems/bulb-switcher-ii 英文原文There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall. Each of the four buttons has a different functionality where: Button 1: Flips…
原文链接: https://leetcode-cn.com/problems/stickers-to-spell-word 英文原文We are given n different types of stickers. Each sticker has a lowercase English word on it. You would like to spell out the given string target by cutting individual letters from your…
原文链接: https://leetcode-cn.com/problems/partition-to-k-equal-sum-subsets 英文原文Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal. Example 1: Input: nums = […
原文链接: https://leetcode-cn.com/problems/pyramid-transition-matrix 英文原文You are stacking blocks to form a pyramid. Each block has a color, which is represented by a single letter. Each row of blocks contains one less block than the row beneath it and is…
原文链接: https://leetcode-cn.com/problems/prime-number-of-set-bits-in-binary-representation 英文原文Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary represe…
原文链接: https://leetcode-cn.com/problems/k-th-symbol-in-grammar 英文原文We build a table of n rows (1-indexed). We start by writing 0 in the 1st row. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and eac…
原文链接: https://leetcode-cn.com/problems/transform-to-chessboard 英文原文You are given an n x n binary grid board. In each move, you can swap any two rows with each other, or any two columns with each other. Return the minimum number of moves to transform …
原文链接: https://leetcode-cn.com/problems/letter-case-permutation 英文原文Given a string s, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. You can retu…
原文链接: https://leetcode-cn.com/problems/split-array-with-same-average 英文原文You are given an integer array nums. You should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and average(A) == average(B). Retur…
原文链接: https://leetcode-cn.com/problems/chalkboard-xor-game 英文原文You are given an array of integers nums represents the numbers written on a chalkboard. Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first.…
原文链接: https://leetcode-cn.com/problems/shortest-path-visiting-all-nodes 英文原文You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an…
原文链接: https://leetcode-cn.com/problems/score-after-flipping-matrix 英文原文You are given an m x n binary matrix grid. A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's …
原文链接: https://leetcode-cn.com/problems/shortest-path-to-get-all-keys 英文原文You are given an m x n grid grid where: '.' is an empty cell. '#' is a wall. '@' is the starting point. Lowercase letters represent keys. Uppercase letters represent locks. You …
原文链接: https://leetcode-cn.com/problems/binary-gap 英文原文Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0. Two 1's are adjacent if…
原文链接: https://leetcode-cn.com/problems/bitwise-ors-of-subarrays 英文原文We have an array arr of non-negative integers. For every (contiguous) subarray sub = [arr[i], arr[i + 1], ..., arr[j]] (with i <= j), we take the bitwise OR of all the elements in su…
原文链接: https://leetcode-cn.com/problems/find-the-shortest-superstring 英文原文Given an array of strings words, return the smallest string that contains each string in words as a substring. If there are multiple valid strings of the smallest length, return…
原文链接: https://leetcode-cn.com/problems/prison-cells-after-n-days 英文原文There are 8 prison cells in a row and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to the following rules: If a cell ha…
原文链接: https://leetcode-cn.com/problems/unique-paths-iii 英文原文You are given an m x n integer array grid where grid[i][j] could be: 1 representing the starting square. There is exactly one starting square. 2 representing the ending square. There is exac…
原文链接: https://leetcode-cn.com/problems/triples-with-bitwise-and-equal-to-zero 英文原文Given an integer array nums, return the number of AND triples. An AND triple is a triple of indices (i, j, k) such that: 0 <= i < nums.length 0 <= j < nums.length 0 <= …
原文链接: https://leetcode-cn.com/problems/minimum-number-of-k-consecutive-bit-flips 英文原文You are given a binary array nums and an integer k. A k-bit flip is choosing a subarray of length k from nums and simultaneously changing every 0 in the subarray to …
原文链接: https://leetcode-cn.com/problems/number-of-squareful-arrays 英文原文An array is squareful if the sum of every pair of adjacent elements is a perfect square. Given an integer array nums, return the number of permutations of nums that are squareful. …
原文链接: https://leetcode-cn.com/problems/complement-of-base-10-integer 英文原文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 …
原文链接: https://leetcode-cn.com/problems/smallest-sufficient-team 英文原文In a project, you have a list of required skills req_skills, and a list of people. The ith person people[i] contains a list of skills that the person has. Consider a sufficient team:…
原文链接: https://leetcode-cn.com/problems/can-make-palindrome-from-substring 英文原文You are given a string s and array queries where queries[i] = [lefti, righti, ki]. We may rearrange the substring s[lefti...righti] for each query and then choose up to ki …
原文链接: https://leetcode-cn.com/problems/number-of-valid-words-for-each-puzzle 英文原文With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: word contains the first letter of puzzle. For each letter in word,…
原文链接: https://leetcode-cn.com/problems/circular-permutation-in-binary-representation 英文原文Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in the…
原文链接: https://leetcode-cn.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters 英文原文You are given an array of strings arr. A string s is formed by the concatenation of a subsequence of arr that has unique characters. Return the …