随笔分类 - LeetCode
摘要:Given two arrays and of equal size, the advantage of with respect to is the number of indices for which . Return any permutation of that maximizes its
阅读全文
摘要:Starting with a positive integer , we reorder the digits in any order (including the original order) such that the leading digit is not zero. Return i
阅读全文
摘要:Given a positive integer , find and return the longest distance between two consecutive 1's in the binary representation of . If there aren't two cons
阅读全文
摘要:Given a matrix , return the transpose of . The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indic
阅读全文
摘要:Find the smallest prime palindrome greater than or equal to . Recall that a number is prime if it's only divisors are 1 and itself, and it is greater
阅读全文
摘要:Given a binary tree rooted at , the depth of each node is the shortest distance to the root. A node is deepest if it has the largest depth possible am
阅读全文
摘要:We are given a binary tree (with root node ), a node, and an integer value . Return a list of the values of all nodes that have a distance from the no
阅读全文
摘要:We have a two dimensional matrix where each value is or . A move consists of choosing any row or column, and toggling each value in that row or column
阅读全文
摘要:At a lemonade stand, each lemonade costs . Customers are standing in a queue to buy from you, and order one at a time (in the order specified by ). Ea
阅读全文
摘要:Given two strings and of lowercase letters, return if and only if we can swap two letters in so that the result equals . Example 1: Example 2: Example
阅读全文
摘要:There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining c
阅读全文
摘要:Given a balanced parentheses string , compute the score of the string based on the following rule: has score 1 has score , where A and B are balanced
阅读全文
摘要:In an exam room, there are N seats in a single row, numbered 0, 1, 2, ..., N-1. When a student enters the room, they must sit in the seat that maximiz
阅读全文
摘要:cars are going to the same destination along a one lane road. The destination is miles away. Each car has a constant speed (in miles per hour), and in
阅读全文
摘要:Let's call an array a mountain if the following properties hold: There exists some Given an array that is definitely a mountain, return any such that
阅读全文
摘要:In a group of N people (labelled `0, 1, 2, ..., N-1`), each person has different amounts of money, and different levels of quietness. For convenience,
阅读全文
摘要:In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. There is at least one empty seat, and at least
阅读全文
摘要:There are piles of stones arranged in a row. The th pile has stones. A move consists of merging exactly consecutive piles into one pile, and the cost
阅读全文
摘要:We have a string S of lowercase letters, and an integer array shifts. Call the shift of a letter, the next letter in the alphabet, (wrapping around so
阅读全文
摘要:Alice has a hand of cards, given as an array of integers. Now she wants to rearrange the cards into groups so that each group is size W, and consists
阅读全文