algorithm-datastructure question with different implementation and different programming language java c++ python (doing) go (todo) scala (todo)