Stacey is coordinating a beach clean-up event with her university's Women in STEM Charity branch. The beach is covered with tin cans of varying weights arranged in a single line, indexed from 0 to n-1.
Stacey uses a scooper that can pick up three adjacent cans at a time. For each selection:
1. She identifies the lightest remaining can, with weight w
2. She uses the scooper to pick up that
Asked in: JPMORGAN
Perform a series of operations on a given array of integers. Each operation consists of two indices that define a subarray to reverse, inclusive of those indices.
Return the resulting array after all operations have been applied in the specified order.
Example
arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
operations = [[0, 9], [4, 5], [3, 6], [2, 7], [1, 8], [0, 9]]
In the first operation,
Asked in: JPMORGAN
Determine the highest value after executing n steps on an infinite 2D grid that initially contains all zeros. The grid is indexed from (1,1) at the bottom-left corner with coordinates increasing upwards and to the right.
For each given coordinate pair (r, c), increment every cell in the rectangle from (1,1) to (r,c) inclusive by 1. After processing all coordinates, return the number of cells th
Asked in: JPMORGAN
Given a matrix of size m * n, where m denotes the number of rows (starting with index 0) and n denotes the number of columns (starting with index 0). The elements in the matrix are populated with values either 1 or 0. A 1 indicates the matrix position is available for establishing the connection, and a 0 indicates the matrix position is not available for establishing the connection.
We need to
Asked in: JPMORGAN
A company needs an efficient strategy to optimize resource allocation for servers based on performance metrics. The performance of each server is represented by performance[i], where 0 โค i < n. A server's rank is defined by the count of distinct performance metrics that are greater than or equal to its own performance metric.
To allocate resources, two positive integer constants, inc and dec, are
Asked in: JPMORGAN
FunWithAnagrams
Two strings are anagrams if they are permutations of each other. In other words, both strings have the
same size and the same characters. For example, "aaagmnrs" is an anagram of "anagrams". Given a
array of strings, remove each string that is an anagram of an earlier string then return the remaining array in sorted order.
Example
str = ['code', 'doce', 'ecod', 'framer', 'f
Asked in: JPMORGAN