Given an integer array
nums, return the largest integer that only occurs once. If no integer occurs once, return-1.
Given an integer array
nums, return the largest integer that only occurs once. If no integer occurs once, return-1.
Given a string
s, returntrueif a permutation of the string could form a palindrome andfalseotherwise.
There is a robot starting at the position
(0, 0)``(0, 0)after it completes its moves.You are given a string
movesthat represents the move sequence of the robot wheremoves[i]represents itsithmove. Valid moves are'R'(right),'L'(left),'U'(up), and'D'(down).Return
trueif the robot returns to the origin after it finishes all of its moves, orfalse
'R'will always make the robot move to the right once,'L'will always make it move left, etc. Also, assume that the magnitude of the robot’s movement is the same for each move.
1275. Find Winner on a Tic Tac Toe Game
Tic-tac-toe is played by two players
AandBon a3 x 3grid. The rules of Tic-Tac-Toe are:
- Players take turns placing characters into empty squares
' '.- The first player
Aalways places'X'characters, while the second playerBalways places'O'characters.'X'and'O'characters are always placed into empty squares, never on filled ones.- The game ends when there are three of the same (non-empty) character filling any row, column, or diagonal.
- The game also ends if all squares are non-empty.
- No more moves can be played if the game is over.
Given a 2D integer array
moveswheremoves[i] = [rowi, coli]indicates that theithmove will be played ongrid[rowi][coli]. return the winner of the game if it exists (AorB). In case the game ends in a draw return"Draw". If there are still movements to play return"Pending".You can assume that
movesis valid (i.e., it follows the rules of Tic-Tac-Toe), the grid is initially empty, andAwill play first.
643. Maximum Average Subarray I
You are given an integer array
numsconsisting ofnelements, and an integerk.Find a contiguous subarray whose length is equal to
kthat has the maximum average value and return this value. Any answer with a calculation error less than10-5will be accepted.
Given an array of integers
nums, calculate the pivot index of this array.The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index’s right.
If the index is on the left edge of the array, then the left sum is
0because there are no elements to the left. This also applies to the right edge of the array.Return the leftmost pivot index. If no such index exists, return
-1.
You have a
RecentCounterclass which counts the number of recent requests within a certain time frame.Implement the
RecentCounterclass:
RecentCounter()Initializes the counter with zero recent requests.int ping(int t)Adds a new request at timet, wheretrepresents some time in milliseconds, and returns the number of requests that has happened in the past3000milliseconds (including the new request). Specifically, return the number of requests that have happened in the inclusive range[t - 3000, t].It is guaranteed that every call to
pinguses a strictly larger value oftthan the previous call.
Given the
rootof a binary tree, return the length of the diameter of the tree.The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the
root.The length of a path between two nodes is represented by the number of edges between them.
2801. Count Stepping Numbers in Range
Given two positive integers
lowandhighrepresented as strings, find the count of stepping numbers in the inclusive range[low, high].A stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly
1.Return an integer denoting the count of stepping numbers in the inclusive range
[low, high].Since the answer may be very large, return it modulo
109 + 7.Note: A stepping number should not have a leading zero.
2800. Shortest String That Contains Three Strings
Given three strings
a,b, andc, your task is to find a string that has the minimum length and contains all three strings as substrings.If there are multiple such strings, return the lexicographically smallest one.
Return a string denoting the answer to the problem.
Notes
- A string
ais lexicographically smaller than a stringb(of the same length) if in the first position whereaandbdiffer, stringahas a letter that appears earlier in the alphabet than the corresponding letter inb.- A substring is a contiguous sequence of characters within a string.