I ran into this while solving a programming question, so seeking help with a subset of the original problem.
The indexes of a, b, and c are provided in a slice of slice of integers ([][]int).
For example:
indexes := [][]int{{0, 10}, {3, 9}, {5, 12}}
where a is found at indices 0 and 10. b is found at indices 3 and 9 c is found at indices 5 and 12.
The goal is to find, programmatically, which of the indexes for a, b and c makes them closest. For example, in the above case, the answer would be 10, 9, 12.
What would be a way to solve this? I have thought about dynamic programming but still cannot figure out how to represent this problem in a recursive way. Non Dp solution also welcome, just looking for ideas not entire solution.
I think I am close but still not there (see min() function) - https://play.golang.org/p/odw9u-JeOPU