Any solution using BST?

  • 0

    since the tag is binary search tree, but I can only find out the solution with slide window.

  • 2

    BST tree actually contains the k+1 elements and you can quickly find the two closest numbers by O(lgn) insert and search operation.

  • 0

    I notice some good solutions here, usages including TreeSet in Java, multiset in C++, all have something to do with BST :p

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.