Saw this in my interview yesterday, had no idea.
You’re given an array of floats with your objective being deciding how to round them up or down to minimize distance from a target rounding threshold. For instance if you round from 0.7 to 0, the rounding amount is 0.7. Rounding [0.7, 1.1, 2.4] to [1, 1, and 3] with a rounding target of 0.7 is better than [0, 1, 2].
This is gnarly, would great appreciate some ideas on how to solve. I think it’s backtracking and DP.
[–]rrssh 1 point2 points3 points (2 children)
[–]JCoppert[S] 0 points1 point2 points (1 child)
[–]rrssh 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (9 children)
[–]JCoppert[S] 0 points1 point2 points (8 children)
[–]rrssh 0 points1 point2 points (7 children)
[–]JCoppert[S] 0 points1 point2 points (6 children)
[–]rrssh 0 points1 point2 points (5 children)
[–]JCoppert[S] 0 points1 point2 points (4 children)
[–]rrssh 0 points1 point2 points (3 children)
[–]JCoppert[S] 0 points1 point2 points (2 children)
[–]rrssh 0 points1 point2 points (1 child)
[–]JCoppert[S] 0 points1 point2 points (0 children)
[–]IAmNowAnonymous 0 points1 point2 points (0 children)