Solving All Nodes Distance K in Binary Tree in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

Example 1:

Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, K = 2

Output: [7,4,1]

Explanation: 
The nodes that are a distance 2 from the target node (with value 5)
have values 7, 4, and 1.

Note:

  1. The given tree is non-empty.
  2. 0 <= K <= 1000.
  • 0 <= K <= 1000.

See the full details of the problem All Nodes Distance K in Binary Tree at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go