随笔分类 - LeetCode
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing. In one operat
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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,
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Given a string s, return the last substring of s in lexicographical order. Example 1: Input: s = "abab" Output: "bab" Explanation: The substrings are
阅读全文
摘要: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
阅读全文