Uber
The given questions was asked in the UBER HACKERRANK, OA
Slolt Machine 2.0
Given: n = 4
spins
['712','246','365','312']
We remove the largest value in each row, and add the max to the resutl.
E.g. Take 7, remove from each row 7, 6, 6, 3
now we have
[1, 2]
[2, 4,]
[3, 5]
[1, 2]
take 5, remove from each row 2, 4, 5, 2
[1]
[2]
[3]
[1]
take 3 remove 1, 2, 5, 1
answer is 7 + 5 + 3 = 15, return 15
Example 2:
1 3 7
1 1 5
3 6 4
1 1 5
7 2 4
take 7 and remove max from each row
1 3
1 1
3 4
1 1
2 4
take 4 and remove max from each row
1
1
3
1
2
take 3 and remove max from each row
7 + 3 + 4 = 14, return 14
The given function was
int slotwise(vector history)