2598. Smallest Missing Non-negative Integer After Operations
You are given a 0-indexed integer array
numsand an integervalue.In one operation, you can add or subtract
valuefrom any element ofnums.
- For example, if
nums = [1,2,3]andvalue = 2, you can choose to subtractvaluefromnums[0]to makenums = [-1,2,3].The MEX (minimum excluded) of an array is the smallest missing non-negative integer in it.
- For example, the MEX of
[-1,2,3]is0while the MEX of[1,0,3]is2.Return the maximum MEX of
numsafter applying the mentioned operation any number of times.
2597. The Number of Beautiful Subsets
You are given an array
numsof positive integers and a positive integerk.A subset of
numsis beautiful if it does not contain two integers with an absolute difference equal tok.Return the number of non-empty beautiful subsets of the array
nums.A subset of
numsis an array that can be obtained by deleting some (possibly none) elements fromnums. Two subsets are different if and only if the chosen indices to delete are different.
2596. Check Knight Tour Configuration
There is a knight on an
n x nchessboard. In a valid configuration, the knight starts at the top-left cell of the board and visits every cell on the board exactly once.You are given an
n x ninteger matrixgridconsisting of distinct integers from the range[0, n * n - 1]wheregrid[row][col]indicates that the cell(row, col)is thegrid[row][col]thcell that the knight visited. The moves are 0-indexed.Return
trueifgridrepresents a valid configuration of the knight’s movements orfalseotherwise.Note that a valid knight move consists of moving two squares vertically and one square horizontally, or two squares horizontally and one square vertically. The figure below illustrates all the possible eight moves of a knight from some cell.
2595. Number of Even and Odd Bits
You are given a positive integer
n.Let
evendenote the number of even indices in the binary representation ofn(0-indexed) with value1.Let
odddenote the number of odd indices in the binary representation ofn(0-indexed) with value1.Return an integer array
answerwhereanswer = [even, odd].
2594. Minimum Time to Repair Cars
You are given an integer array ranks representing the ranks of some mechanics. ranksi is the rank of the ith mechanic. A mechanic with a rank r can repair n cars in r * n2 minutes.
You are also given an integer cars representing the total number of cars waiting in the garage to be repaired.
Return the minimum time taken to repair all the cars.
Note: All the mechanics can repair the cars simultaneously.
2593. Find Score of an Array After Marking All Elements
You are given an array nums consisting of positive integers.
Starting with score = 0, apply the following algorithm:
- Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index.
- Add the value of the chosen integer to score.
- Mark the chosen element and its two adjacent elements if they exist.
- Repeat until all the array elements are marked.
Return the score you get after applying the above algorithm.
2592. Maximize Greatness of an Array
You are given a 0-indexed integer array nums. You are allowed to permute nums into a new array perm of your choosing.
We define the greatness of nums be the number of indices 0 <= i < nums.length for which perm[i] > nums[i].
Return the maximum possible greatness you can achieve after permuting nums.
2591. Distribute Money to Maximum Children
You are given an integer money denoting the amount of money (in dollars) that you have and another integer children denoting the number of children that you must distribute the money to.
You have to distribute the money according to the following rules:
- All money must be distributed.
- Everyone must receive at least 1 dollar.
- Nobody receives 4 dollars.
Return the maximum number of children who may receive exactly 8 dollars if you distribute the money according to the aforementioned rules. If there is no way to distribute the money, return -1.