AMAZON & MICROSOFT Question – Solved

7 Live
Coding Wars There are 'N' coders standing in a line, where i denotes the ith position of a coder with a rating of Ri. All ratings are distinct. You have to form a team of 3 from amongst them with the condition: Any three coders with positions (i, j, k) and ratings ("Ri< Rj< Rk" or "Ri > Rj > Rk") and(1 <= i < j < k <= N) You have to find out how many such teams exist (1 coder can be part of multiple teams). Input: N = 5 Ratings = [5, 2, 3, 1, 4] Output: 3 (5, 2, 1), (5, 3, 1), (2, 3, 4)

Asked in: AMAZON MICROSOFT

Image of the Question

Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |