摘要:
A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number
阅读全文
posted @ 2021-09-23 12:21
Grandyang
阅读(835)
推荐(0)
摘要:
When you try to debug C++ in Visual Studio Code on Mac, you might have the following error: Errors exist after running preLaunchTask 'C/C++: clang++ b
阅读全文
posted @ 2021-09-20 11:03
Grandyang
阅读(677)
推荐(0)
摘要:
On an 8x8 chessboard, there can be multiple Black Queens and one White King. Given an array of integer coordinates queens that represents the position
阅读全文
posted @ 2021-09-17 23:53
Grandyang
阅读(395)
推荐(0)
摘要:
Balanced strings are those that have an equal quantity of 'L' and 'R' characters. Given a balanced string s, split it in the maximum amount of balance
阅读全文
posted @ 2021-09-13 23:22
Grandyang
阅读(669)
推荐(0)
摘要:
Given an integer n, your task is to count how many strings of length n can be formed under the following rules: Each character is a lower case vowel (
阅读全文
posted @ 2021-09-12 11:18
Grandyang
阅读(606)
推荐(0)
摘要:
In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty. Return the ma
阅读全文
posted @ 2021-09-10 12:54
Grandyang
阅读(725)
推荐(0)
摘要:
When use the VsVim plugin in Visual Studio for Mac and type the closing part of a parenthesis, you might see ClosePair(')') pop up with awkward sound.
阅读全文
posted @ 2021-09-10 09:55
Grandyang
阅读(142)
推荐(0)
摘要:
Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that th
阅读全文
posted @ 2021-09-08 12:14
Grandyang
阅读(582)
推荐(1)
摘要:
We have n chips, where the position of the ith chip is position[i]. We need to move all the chips to the same position. In one step, we can change the
阅读全文
posted @ 2021-09-05 02:39
Grandyang
阅读(463)
推荐(0)
摘要:
In an n*n grid, there is a snake that spans 2 cells and starts moving from the top left corner at (0, 0) and (0, 1). The grid has empty cells represen
阅读全文
posted @ 2021-09-04 11:09
Grandyang
阅读(526)
推荐(0)
摘要:
You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing t
阅读全文
posted @ 2021-08-31 23:51
Grandyang
阅读(947)
推荐(0)
摘要:
There is Client-Side Library under the Add when I right click the project on Visual Studio for Mac. So I searched on Google, and find this post LibMan
阅读全文
posted @ 2021-08-31 13:02
Grandyang
阅读(214)
推荐(0)
摘要:
You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] -
阅读全文
posted @ 2021-08-29 02:55
Grandyang
阅读(454)
推荐(0)
摘要:
Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. Exam
阅读全文
posted @ 2021-08-29 02:05
Grandyang
阅读(666)
推荐(0)
摘要:
Design a Skiplist without using any built-in libraries. A skiplist is a data structure that takes O(log(n)) time to add, erase and search. Comparing w
阅读全文
posted @ 2021-08-28 09:09
Grandyang
阅读(700)
推荐(0)
摘要:
There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it's equal to -1 if the i-th
阅读全文
posted @ 2021-08-25 23:14
Grandyang
阅读(598)
推荐(0)
摘要:
You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string. Y
阅读全文
posted @ 2021-08-23 07:24
Grandyang
阅读(1089)
推荐(0)
摘要:
An ugly number is a positive integer that is divisible by a, b, or c. Given four integers n, a, b, and c, return the nth ugly number. Example 1: Input
阅读全文
posted @ 2021-08-22 07:18
Grandyang
阅读(641)
推荐(0)
摘要:
Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. Return a list of pairs i
阅读全文
posted @ 2021-08-19 21:43
Grandyang
阅读(1579)
推荐(0)
摘要:
There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] re
阅读全文
posted @ 2021-08-19 21:10
Grandyang
阅读(1615)
推荐(0)
摘要:
Given an integer array arr and an integer k, modify the array by repeating it k times. For example, if arr = [1, 2] and k = 3 then the modified array
阅读全文
posted @ 2021-08-16 06:13
Grandyang
阅读(465)
推荐(0)
摘要:
You are given a string s that consists of lower case English letters and brackets. Reverse the strings in each pair of matching parentheses, starting
阅读全文
posted @ 2021-08-15 04:48
Grandyang
阅读(622)
推荐(0)
摘要:
Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in
阅读全文
posted @ 2021-08-12 23:10
Grandyang
阅读(501)
推荐(0)
摘要:
Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operat
阅读全文
posted @ 2021-08-11 12:13
Grandyang
阅读(808)
推荐(0)
摘要:
Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, y
阅读全文
posted @ 2021-08-09 01:37
Grandyang
阅读(673)
推荐(0)
摘要:
Given a date, return the corresponding day of the week for that date. The input is given as three integers representing the day, month and year respec
阅读全文
posted @ 2021-08-08 02:25
Grandyang
阅读(620)
推荐(0)
摘要:
A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the di
阅读全文
posted @ 2021-08-05 21:51
Grandyang
阅读(442)
推荐(0)
摘要:
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 e
阅读全文
posted @ 2021-08-03 21:41
Grandyang
阅读(683)
推荐(0)
摘要:
Given a string s, we make queries on substrings of s. For each query queries[i] = [left, right, k], we may rearrange the substring s[left], ..., s[rig
阅读全文
posted @ 2021-08-02 10:23
Grandyang
阅读(470)
推荐(0)
摘要:
Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) (Recall that an integer is prime if and only if it
阅读全文
posted @ 2021-07-31 21:36
Grandyang
阅读(486)
推荐(0)
摘要:
You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. Impleme
阅读全文
posted @ 2021-07-29 22:43
Grandyang
阅读(388)
推荐(0)
摘要:
Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing so,
阅读全文
posted @ 2021-07-27 21:55
Grandyang
阅读(829)
推荐(0)
摘要:
Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s. For example, if s = "dcce" then f(s) = 2 b
阅读全文
posted @ 2021-07-26 03:03
Grandyang
阅读(351)
推荐(0)
摘要:
A transaction is possibly invalid if: the amount exceeds $1000, or; if it occurs within (and including) 60 minutes of another transaction with the sam
阅读全文
posted @ 2021-07-22 22:58
Grandyang
阅读(640)
推荐(0)
摘要:
Given a string s, return the last substring of s in lexicographical order. Example 1: Input: s = "abab" Output: "bab" Explanation: The substrings are
阅读全文
posted @ 2021-07-21 23:01
Grandyang
阅读(502)
推荐(0)
摘要:
Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the ne
阅读全文
posted @ 2021-07-20 22:27
Grandyang
阅读(903)
推荐(0)
摘要:
Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum
阅读全文
posted @ 2021-07-17 09:43
Grandyang
阅读(425)
推荐(0)
摘要:
You are given an array of strings words and a string chars. A string is good if it can be formed by characters from chars (each character can only be
阅读全文
posted @ 2021-07-15 09:27
Grandyang
阅读(366)
推荐(0)
摘要:
Design a data structure that efficiently finds the majority element of a given subarray. The majority element of a subarray is an element that occurs
阅读全文
posted @ 2021-07-14 13:21
Grandyang
阅读(495)
推荐(0)
摘要:
Given a string text, we are allowed to swap two of the characters in the string. Find the length of the longest substring with repeated characters. Ex
阅读全文
posted @ 2021-07-09 23:25
Grandyang
阅读(728)
推荐(0)