3718. Smallest Missing Multiple of K
Given an integer array
numsand an integerk, return the smallest positive multiple ofkthat is missing fromnums.A multiple of
kis any positive integer divisible byk.
3718. Smallest Missing Multiple of K
Given an integer array
numsand an integerk, return the smallest positive multiple ofkthat is missing fromnums.A multiple of
kis any positive integer divisible byk.
2011. Final Value of Variable After Performing Operations
There is a programming language with only four operations and one variable
X:
++XandX++increments the value of the variableXby1.--XandX--decrements the value of the variableXby1.Initially, the value of
Xis0.Given an array of strings
operationscontaining a list of operations, return the final value ofXafter performing all the operations.
3715. Sum of Perfect Square Ancestors
You are given an integer
nand an undirected tree rooted at node 0 withnnodes numbered from 0 ton - 1. This is represented by a 2D arrayedgesof lengthn - 1, whereedges[i] = [ui, vi]indicates an undirected edge between nodesuiandvi.You are also given an integer array
nums, wherenums[i]is the positive integer assigned to nodei.Define a value
tias the number of ancestors of nodeisuch that the productnums[i] * nums[ancestor]is a perfect square.Return the sum of all
tivalues for all nodesiin range[1, n - 1].Note:
- In a rooted tree, the ancestors of node
iare all nodes on the path from nodeito the root node 0, excludingiitself.
3714. Longest Balanced Substring II
You are given a string
sconsisting only of the characters'a','b', and'c'.A substring of
sis called balanced if all distinct characters in the substring appear the same number of times.Return the length of the longest balanced substring of
s.
3713. Longest Balanced Substring I
You are given a string
sconsisting of lowercase English letters.A substring of
sis called balanced if all distinct characters in the substring appear the same number of times.Return the length of the longest balanced substring of
s.
3712. Sum of Elements With Frequency Divisible by K
You are given an integer array
numsand an integerk.Return an integer denoting the sum of all elements in
numswhose frequency is divisible byk, or 0 if there are no such elements.Note: An element is included in the sum exactly as many times as it appears in the array if its total frequency is divisible by
k.
3710. Maximum Partition Factor
You are given a 2D integer array
points, wherepoints[i] = [xi, yi]represents the coordinates of theithpoint on the Cartesian plane.The Manhattan distance between two points
points[i] = [xi, yi]andpoints[j] = [xj, yj]is|xi - xj| + |yi - yj|.Split the
npoints into exactly two non-empty groups. The partition factor of a split is the minimum Manhattan distance among all unordered pairs of points that lie in the same group.Return the maximum possible partition factor over all valid splits.
Note: A group of size 1 contributes no intra-group pairs. When
n = 2(both groups size 1), there are no intra-group pairs, so define the partition factor as 0.
3709. Design Exam Scores Tracker
Alice frequently takes exams and wants to track her scores and calculate the total scores over specific time periods.
Implement the
ExamTrackerclass:
ExamTracker(): Initializes theExamTrackerobject.void record(int time, int score): Alice takes a new exam at timetimeand achieves the scorescore.long long totalScore(int startTime, int endTime): Returns an integer that represents the total score of all exams taken by Alice betweenstartTimeandendTime(inclusive). If there are no recorded exams taken by Alice within the specified time interval, return 0.It is guaranteed that the function calls are made in chronological order. That is,
- Calls to
record()will be made with strictly increasingtime.- Alice will never ask for total scores that require information from the future. That is, if the latest
record()is called withtime = t, thentotalScore()will always be called withstartTime <= endTime <= t.
3708. Longest Fibonacci Subarray
You are given an array of positive integers
nums.A Fibonacci array is a contiguous sequence whose third and subsequent terms each equal the sum of the two preceding terms.
Return the length of the longest Fibonacci subarray in
nums.Note: Subarrays of length 1 or 2 are always Fibonacci.
You are given a string
sconsisting of lowercase English letters.The score of a string is the sum of the positions of its characters in the alphabet, where
'a' = 1,'b' = 2, …,'z' = 26.Determine whether there exists an index
isuch that the string can be split into two non-empty \substrings**s[0..i]ands[(i + 1)..(n - 1)]that have equal scores.Return
trueif such a split exists, otherwise returnfalse.