You are given an integer array
numsof lengthnand an integer arrayqueries.Let
gcdPairsdenote an array obtained by calculating the GCD of all possible pairs(nums[i], nums[j]), where0 <= i < j < n, and then sorting these values in ascending order.For each query
queries[i], you need to find the element at indexqueries[i]ingcdPairs.Return an integer array
answer, whereanswer[i]is the value atgcdPairs[queries[i]]for each query.The term
gcd(a, b)denotes the greatest common divisor ofaandb.
3311. Construct 2D Grid Matching Graph Layout
You are given a 2D integer array
edgesrepresenting an undirected graph havingnnodes, whereedges[i] = [ui, vi]denotes an edge between nodesuiandvi.Construct a 2D grid that satisfies these conditions:
- The grid contains all nodes from
0ton - 1in its cells, with each node appearing exactly once.- Two nodes should be in adjacent grid cells (horizontally or vertically) if and only if there is an edge between them in
edges.It is guaranteed that
edgescan form a 2D grid that satisfies the conditions.Return a 2D integer array satisfying the conditions above. If there are multiple solutions, return any of them.
3310. Remove Methods From Project
You are maintaining a project that has
nmethods numbered from0ton - 1.You are given two integers
nandk, and a 2D integer arrayinvocations, whereinvocations[i] = [ai, bi]indicates that methodaiinvokes methodbi.There is a known bug in method
k. Methodk, along with any method invoked by it, either directly or indirectly, are considered suspicious and we aim to remove them.A group of methods can only be removed if no method outside the group invokes any methods within it.
Return an array containing all the remaining methods after removing all the suspicious methods. You may return the answer in any order. If it is not possible to remove all the suspicious methods, none should be removed.
3309. Maximum Possible Number by Binary Concatenation
You are given an array of integers
numsof size 3.Return the maximum possible number whose binary representation can be formed by concatenating the binary representation of all elements in
numsin some order.Note that the binary representation of any number does not contain leading zeros.
1331. Rank Transform of an Array
Given an array of integers
arr, replace each element with its rank.The rank represents how large the element is. The rank has the following rules:
- Rank is an integer starting from 1.
- The larger the element, the larger the rank. If two elements are equal, their rank must be the same.
- Rank should be as small as possible.