Question 4 K th Clostest Point to <0,0,0>

High Level

  • Graph?

    • vertex:(x,y,z)

    • edge: x,y,z +1

    • graph representation:

  • method:

    • bfs-2

Middle Level

  • using priorityQueue

  • inital state: (0,0,0)

  • expand:第几次expand出现的就是matrix里第几小的元素

  • generate: x,y, z choose one to plus 1

  • termination condition: when the k-th element is about to be expanded

  • deduplication: 不去同样的x,y,z

Last updated