
math
文章平均质量分 75
ForABiggerWorld
这个作者很懒,什么都没留下…
展开
-
1717. Maximum Score From Removing Substrings
You are given a stringsand two integersxandy. You can perform two types of operations any number of times.Remove substring"ab"and gainxpoints. For example, when removing"ab"from"cabxbae"it becomes"cxbae". Remove substring"ba"and gain...原创 2021-01-12 21:15:45 · 283 阅读 · 0 评论 -
1442. Count Triplets That Can Form Two Arrays of Equal XOR
Given an array ofintegersarr.We want to select three indicesi,jandkwhere(0 <= i < j <= k < arr.length).Let's defineaandbas follows:a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1] b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]Note that^...原创 2020-05-12 23:49:10 · 328 阅读 · 0 评论 -
1424. Diagonal Traverse II
Given a list of lists of integers,nums,return all elements ofnumsin diagonal order as shown in the below images.Example 1:Input: nums = [[1,2,3],[4,5,6],[7,8,9]]Output: [1,4,2,7,5,3,...原创 2020-05-01 22:23:16 · 371 阅读 · 0 评论 -
1419. Minimum Number of Frogs Croaking
Given the stringcroakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple “croak” are mixed.Return the ...原创 2020-04-25 16:48:02 · 322 阅读 · 0 评论 -
1415. The k-th Lexicographical String of All Happy Strings of Length n
Ahappy stringis a string that:consists only of letters of the set['a', 'b', 'c']. s[i] != s[i + 1]for all values ofifrom1tos.length - 1(string is 1-indexed).For example, strings"abc", "...原创 2020-04-21 21:02:29 · 395 阅读 · 0 评论 -
1414. Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
Given the numberk,return the minimum number of Fibonacci numbers whose sum is equal tok, whether a Fibonacci number could be used multiple times.The Fibonacci numbers are defined as:F1= 1 F2...原创 2020-04-21 20:59:45 · 490 阅读 · 0 评论 -
1404. Number of Steps to Reduce a Number in Binary Representation to One
Given a numbersin their binary representation. Return the number of steps to reduce it to 1 under the following rules: If the current number is even, you have to divide it by 2. If the curre...原创 2020-04-07 21:58:28 · 302 阅读 · 0 评论 -
1291. Sequential Digits
Aninteger hassequential digitsif and only if each digit in the number is one more than the previous digit.Return asortedlist of all the integersin the range[low, high]inclusive that have seq...原创 2020-01-31 11:52:40 · 259 阅读 · 0 评论 -
1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance
There arencities numbered from0ton-1. Given the arrayedgeswhereedges[i] = [fromi, toi, weighti]represents a bidirectional and weighted edge between citiesfromiandtoi, and given the integer...原创 2020-01-30 23:05:58 · 369 阅读 · 0 评论 -
1310. XOR Queries of a Subarray
Given the arrayarrof positive integers and the arrayquerieswherequeries[i] = [Li,Ri],for each queryicompute theXORof elements fromLitoRi(that is,arr[Li]xorarr[Li+1]xor...xorarr[R...原创 2020-01-30 22:41:57 · 231 阅读 · 0 评论 -
1307. Verbal Arithmetic Puzzle
Given an equation, represented bywordson left side and theresulton right side.You need to check if the equation is solvableunder the following rules:Each character is decoded as one digit (0 ...原创 2020-01-30 22:37:12 · 449 阅读 · 0 评论 -
1250. Check If It Is a Good Array
Given an arraynumsofpositive integers. Your task is to select some subset ofnums, multiply each element by an integer and add all these numbers.The array is said to begoodif you can obtain a su...原创 2019-11-04 22:18:00 · 193 阅读 · 0 评论 -
1248. Count Number of Nice Subarrays
Given an array of integersnumsand an integerk. Asubarrayis calledniceif there arekodd numbers on it.Return the number ofnicesub-arrays.Example 1:Input: nums = [1,1,2,1,1], k = 3O...原创 2019-11-04 22:15:56 · 375 阅读 · 0 评论 -
1247. Minimum Swaps to Make Strings Equal
You are given two stringss1ands2of equal lengthconsisting of letters"x"and"y"only. Your task is tomake these two strings equal to each other. You can swap any two characters that belong tod...原创 2019-11-04 22:14:29 · 377 阅读 · 0 评论 -
1238. Circular Permutation in Binary Representation
Given 2 integersnandstart. Your task is returnanypermutationpof(0,1,2.....,2^n -1)such that :p[0] = start p[i]andp[i+1]differ by only one bit in their binary representation. p[0]andp...原创 2019-11-02 22:27:11 · 307 阅读 · 0 评论 -
1224. Maximum Equal Frequency
Given an arraynumsof positive integers, return the longest possible length of an array prefix ofnums, such that it is possible to removeexactly oneelement from this prefix so that every number th...原创 2019-10-19 19:50:00 · 449 阅读 · 0 评论 -
984. String Without AAA or BBB
Given two integers A and B, return any string S such that:S has length A + B and contains exactly A 'a' letters, and exactly B 'b' letters; The substring 'aaa' does not occur in S; The substring '...原创 2019-01-27 18:13:01 · 321 阅读 · 0 评论 -
1071. Greatest Common Divisor of Strings
For stringsSandT, we say "TdividesS" if and only ifS = T + ... + T (Tconcatenated with itself 1 or more times)Return the largest stringXsuch thatXdividesstr1andXdividesstr2.Exa...原创 2019-06-02 13:34:12 · 554 阅读 · 0 评论 -
1053. Previous Permutation With One Swap
Given an arrayAof positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller thanA, that can bemade with one swap(Aswapexchanges the position...原创 2019-05-26 12:00:04 · 272 阅读 · 0 评论 -
1042. Flower Planting With No Adjacent
You haveNgardens, labelled1toN. In each garden, you want to plant one of 4 types of flowers.paths[i] = [x, y]describes the existence of a bidirectional path from gardenxto gardeny.Also, ...原创 2019-05-12 14:34:42 · 445 阅读 · 0 评论 -
1041. Robot Bounded In Circle
On an infinite plane, arobot initially stands at(0, 0)and faces north.The robot can receive one of three instructions:"G": go straight 1 unit; "L": turn 90 degrees to the left; "R": turn 90 d...原创 2019-05-12 14:19:13 · 277 阅读 · 0 评论 -
1036. Escape a Large Maze
In a 1 million by 1 million grid, the coordinates of each grid square are(x, y)with0 <= x, y < 10^6.We start at thesourcesquare and want to reach thetargetsquare. Each move, we can wal...原创 2019-04-28 13:24:44 · 613 阅读 · 0 评论 -
976. Largest Perimeter Triangle
Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths.If it is impossible to form any triangle of non-zero area, return ...原创 2019-01-13 12:00:48 · 218 阅读 · 0 评论 -
1025. Divisor Game
Alice and Bob take turns playing a game, with Alice starting first.Initially, there is a numberNon the chalkboard. On each player's turn, that player makes amoveconsisting of:Choosinganyxw...原创 2019-04-14 20:09:46 · 626 阅读 · 1 评论 -
1017. Convert to Base -2
Given a numberN, return a string consisting of"0"s and"1"sthat represents its value in base-2(negative two).The returned string must have no leading zeroes, unless the string is"0".Examp...原创 2019-03-31 14:33:05 · 317 阅读 · 0 评论 -
1022. Smallest Integer Divisible by K
Given a positive integerK, you need find thesmallestpositive integerNsuch thatNis divisible byK, andNonly contains the digit1.Return thelength ofN. If there is no suchN,return -1....原创 2019-03-24 12:22:24 · 407 阅读 · 0 评论 -
1001. Grid Illumination
On a N x N grid of cells, each cell (x, y) with 0 <= x < N and 0 <= y < N has a lamp.Initially, some number of lamps are on. lamps[i] tells us the location of the i-th lamp that is on. ...原创 2019-02-24 12:06:11 · 250 阅读 · 0 评论 -
995. Minimum Number of K Consecutive Bit Flips
In an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to ...原创 2019-02-17 20:59:43 · 320 阅读 · 0 评论 -
991. Broken Calculator
On a broken calculator that has a number showing on its display, we can perform two operations:Double: Multiply the number on the display by 2, or; Decrement: Subtract 1 from the number on the disp...原创 2019-02-10 14:56:56 · 402 阅读 · 0 评论 -
1072. Flip Columns For Maximum Number of Equal Rows
Given amatrixconsisting of 0s and 1s, we may choose any number of columns in the matrix and flipeverycell in that column. Flipping a cell changes the value of that cell from 0 to 1 or from 1 to 0...原创 2019-06-02 13:35:41 · 360 阅读 · 0 评论 -
1073. Adding Two Negabinary Numbers
Given two numbersarr1andarr2in base-2, return the result of adding them together.Each number is given inarray format: as an array of 0s and 1s, from most significant bit to least significant ...原创 2019-06-02 13:36:13 · 267 阅读 · 0 评论 -
1074. Number of Submatrices That Sum to Target
Given amatrix, and atarget, return the number of non-empty submatrices that sum totarget.A submatrixx1, y1, x2, y2is the set of all cellsmatrix[x][y]withx1 <= x <= x2andy1 <= y &l...原创 2019-06-02 13:45:18 · 394 阅读 · 0 评论 -
287. Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fi...原创 2018-05-24 16:19:19 · 145 阅读 · 0 评论 -
1201. Ugly Number III
Write a program to find then-th ugly number.Ugly numbers arepositive integerswhich are divisible byaorborc.Example 1:Input: n = 3, a = 2, b = 3, c = 5Output: 4Explanation: The ugly...原创 2019-09-22 14:01:17 · 508 阅读 · 0 评论 -
1191. K-Concatenation Maximum Sum
Given an integer arrayarrand an integerk, modify the array by repeating itktimes.For example, ifarr= [1, 2]andk = 3then the modified array will be[1, 2, 1, 2, 1, 2].Return the maximum s...原创 2019-09-15 15:01:37 · 459 阅读 · 0 评论 -
1186. Maximum Subarray Sum with One Deletion
Given an array of integers, return the maximum sum for anon-emptysubarray (contiguous elements) with at most one element deletion.In other words, you want to choose a subarray and optionally delete...原创 2019-09-08 13:47:38 · 343 阅读 · 0 评论 -
1178. Number of Valid Words for Each Puzzle
With respect to a givenpuzzlestring, awordisvalidif both the following conditions are satisfied:wordcontains the first letter ofpuzzle. For each letter inword, that letter is inpuzzle. F...原创 2019-09-01 14:58:59 · 528 阅读 · 0 评论 -
1157. Online Majority Element In Subarray
Implementing the classMajorityChecker, which has the following API:MajorityChecker(int[] arr)constructs an instance of MajorityChecker with the given arrayarr; int query(int left, int right, int...原创 2019-08-11 13:40:30 · 298 阅读 · 0 评论 -
1140. Stone Game II
Alexand Lee continue theirgames with piles of stones. There are a number ofpilesarranged in a row, and each pile has a positive integer number of stonespiles[i]. The objective of the game is to...原创 2019-07-28 13:24:31 · 591 阅读 · 0 评论 -
5133. Maximum of Absolute Value Expression
Given two arrays of integers with equal lengths, return the maximum value of:|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|where the maximum is taken over all0 <= i, j < arr1.length....原创 2019-07-21 12:01:06 · 373 阅读 · 0 评论