Uber OA
Anonymous User
1470

Minimum number of additions to make array sorted (worded as adding blocks to towers)

EX:

arr = [1, 4, 3, 2]
result = 4 (Add 4 to the first item)	
	
arr = [2, 3, 2, 3]
result = 4 (Add 2 to the last 2 items)

	
arr = [5, 7, 9, 4, 11]
result = 9 (add 2 to 5, add 1 to 7, 6 to 4)

Could not figure this out, i assume this might be DP?

Comments (8)
No comments yet.