2685. Count the Number of Complete Components
You are given an integer
n. There is an undirected graph withnvertices, numbered from0ton - 1. You are given a 2D integer arrayedgeswhereedges[i] = [ai, bi]denotes that there exists an undirected edge connecting verticesaiandbi.Return the number of complete connected components of the graph.
A connected component is a subgraph of a graph in which there exists a path between any two vertices, and no vertex of the subgraph shares an edge with a vertex outside of the subgraph.
A connected component is said to be complete if there exists an edge between every pair of its vertices.
2684. Maximum Number of Moves in a Grid
You are given a 0-indexed
m x nmatrixgridconsisting of positive integers.You can start at any cell in the first column of the matrix, and traverse the grid in the following way:
- From a cell
(row, col), you can move to any of the cells:(row - 1, col + 1),(row, col + 1)and(row + 1, col + 1)such that the value of the cell you move to, should be strictly bigger than the value of the current cell.Return the maximum number of moves that you can perform.
A 0-indexed array
derivedwith lengthnis derived by computing the bitwise XOR (⊕) of adjacent values in a binary arrayoriginalof lengthn.Specifically, for each index
iin the range[0, n - 1]:
- If
i = n - 1, thenderived[i] = original[i] ⊕ original[0].- Otherwise,
derived[i] = original[i] ⊕ original[i + 1].Given an array
derived, your task is to determine whether there exists a valid binary arrayoriginalthat could have formedderived.Return *true if such an array exists or false otherwise.*
- A binary array is an array containing only 0’s and 1’s
2682. Find the Losers of the Circular Game
There are
nfriends that are playing a game. The friends are sitting in a circle and are numbered from1tonin clockwise order. More formally, moving clockwise from theithfriend brings you to the(i+1)thfriend for1 <= i < n, and moving clockwise from thenthfriend brings you to the1stfriend.The rules of the game are as follows:
1stfriend receives the ball.
- After that,
1stfriend passes it to the friend who isksteps away from them in the clockwise direction.- After that, the friend who receives the ball should pass it to the friend who is
2 * ksteps away from them in the clockwise direction.- After that, the friend who receives the ball should pass it to the friend who is
3 * ksteps away from them in the clockwise direction, and so on and so forth.In other words, on the
ithturn, the friend holding the ball should pass it to the friend who isi * ksteps away from them in the clockwise direction.The game is finished when some friend receives the ball for the second time.
The losers of the game are friends who did not receive the ball in the entire game.
Given the number of friends,
n, and an integerk, return the array answer, which contains the losers of the game in the ascending order.
You are given a 0-indexed integer array
numsrepresenting the strength of some heroes. The power of a group of heroes is defined as follows:
- Let
i0,i1, … ,ikbe the indices of the heroes in a group. Then, the power of this group ismax(nums[i0], nums[i1], ... ,nums[ik])2 * min(nums[i0], nums[i1], ... ,nums[ik]).Return the sum of the power of all non-empty groups of heroes possible. Since the sum could be very large, return it modulo
109 + 7.
You are given a 0-indexed integer array
numsof lengthnand an integerk. In an operation, you can choose an element and multiply it by2.Return the maximum possible value of
nums[0] | nums[1] | ... | nums[n - 1]that can be obtained after applying the operation on nums at mostktimes.Note that
a | bdenotes the bitwise or between two integersaandb.
You are given a 0-indexed 2D integer array
nums. Initially, your score is0. Perform the following operations until the matrix becomes empty:
- From each row in the matrix, select the largest number and remove it. In the case of a tie, it does not matter which number is chosen.
- Identify the highest number amongst all those removed in step 1. Add that number to your score.
Return the final score.
2678. Number of Senior Citizens
You are given a 0-indexed array of strings
details. Each element ofdetailsprovides information about a given passenger compressed into a string of length15. The system is such that:
- The first ten characters consist of the phone number of passengers.
- The next character denotes the gender of the person.
- The following two characters are used to indicate the age of the person.
- The last two characters determine the seat allotted to that person.
Return the number of passengers who are strictly more than 60 years old.