Round 1
Questions:
Q1
A grid-like representation of an image is divided into n rows and m columns, with each cell containing pixel intensity values.
The aim is to improve the visibility of specific objects in the image.
Each pixel located at position (i, j) within the grid corresponds to a specific element in the image, where 0 ≤ i < n and 0 ≤ j < m.
The pixel's intensity or value is denoted by pixelintensity[i][j].
The goal is to adjust the intensity of each pixel to ensure that no pixel in the previous rows, where 0 ≤ i' < i in the same column, has a brightness higher or equal to the given pixel. To achieve this, a pixel's intensity can be increased at a cost of one unit per unit of increase.
Determine the minimum cost to achieve the desired intensity in all n * m pixels.
Example
A grid with three rows and two columns is given:
pixelintensity = [[2, 5], [7, 4], [3, 51]].
Currently, the intensity levels in cells (1, 1), (2, 0), and (2, 1) are not appropriate.
Add 5 to the third row of the first column to get values 2, 7, and 8. Add 2 to the second and third rows in the second column to get values 5, 6, and 7. Both columns are now strictly increasing from top to bottom as required. The cost of the enhancements is 5 + 2 + 2 = 9, which is the minimum possible.
Function Description
Complete the function getMinimumCost in the editor below.
getMinimumCost takes the following arguments:
Q2
FC Codelona is trying to assemble a team from a roster of available players. They have a minimum number of players they want to sign, and each player needs to have a skill rating within a certain range.
Given a list of players' skill levels with desired upper and lower bounds, determine how many teams can be created from the list.
Example
skills = [12, 4, 6, 13, 5, 10]
minPlayers = 3
minLevel = 4
maxLevel = 10
- The list includes players with skill levels [12, 4, 6, 13, 5, 10].
- They want to hire at least 3 players with skill levels between 4 and 10, inclusive.
- Four of the players with the following skill levels {4, 6, 5, 10} meet the criteria.
- There are 5 ways to form a team of at least 3 players: {4, 5, 6}, {4, 6, 10}, {4, 5, 10}, {5, 6, 10}, and {4, 5, 6, 10}.
- Return 5.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.