Problem Statement

You are the technical director of WSPT radio, serving listeners nationwide. For simplicity’s sake we can consider each listener to live along a horizontal line stretching from 0 (west) to 1000 (east).

Given a list of N listeners, and a list of M radio towers, each placed at various locations along this line, determine what the minimum broadcast range would have to be in order for each listener’s home to be covered.

For example, suppose listeners = [1, 5, 11, 20], and towers = [4, 8, 15]. In this case the minimum range would be 5, since that…


This is part 4of the series — working with Binary Trees in Go. In this article, I will show how to perform zigzag level order traversal of a binary tree in Go.

  • Part 2 Binary Tree Traversals in Go — using iteration (access it here)
  • Part 3 Level order Traversal of Binary Trees in Go (access it here)
  • Part4 Zigzag Level Order Traversal of a Binary Tree in Go (this article)
  • Part 5 Right side View of a Binary Tree in Go
  • Part 6 Binary Tree Serialization in Go

This is part 3 of the series — working with Binary Trees in Go. In this article, I will show how to perform level order traversal of a binary tree in Go.

  • Part 2 Binary Tree Traversals in Go — using iteration (access it here)
  • Part 3 Level order Traversal of Binary Trees in Go (this article)
  • Part4 Zigzag Level Order Traversal of Binary Trees in Go (access it here)
  • Part 5 Right side View of a Binary Tree in Go
  • Part 6 Binary Tree Serialization in Go

This is part 2 of the series — working with Binary Trees in Go. I would like to show iterative implementation of the three traversal algorithms discussed in part 1 of the series.

  • Part 2 Binary Tree Traversals in Go — using iteration (this article)
  • Part 3 Level order Traversal of Binary Trees in Go (access it here)
  • Part4 Zigzag Level Order Traversal of Binary Trees in Go (access it here)
  • Part 5 Right side View of a Binary Tree in Go
  • Part 6 Binary Tree Serialization in Go

When I first began my journey with Go I wanted to pick several simple and intuitive problems and code their solutions in Go. This not only helped me in mastering the language syntax and understanding the coding concepts specific to Go, but also was critical in developing the skills required to take the algorithms from their descriptive form to working solutions in Go.

One can find many such problems in Data Structures and Algorithms course. Websites such as Leetcode have hundreds of problems to test not only your algorithmic skills but coding skills. Here in this article, I will show…


Given an integer array nums, return the length of the longest strictly increasing subsequence.

A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7]

Example:

Input: nums = [2, 1, 0, 3, 2, 3]
Output: 3
Explanation: The longest increasing subsequence is [1, 2, 3], therefore the length is 3
Note that there can be multiple longest increasing subsequences of same length


Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. (This is Leetcode problem # 347)

Example:

Input: nums = [1,1,1,2,2,3], k = 2

Output: [1,2]

Explanation:

1 occurs three times and 2 occurs two times in the input. Those two elements are the top-2 frequent elements and hence the output is [1, 2].

Initial Thoughts

This is a good algorithmic problem. It not only helps in practicing my algorithm skills but also helps in mastering Go skills. In particular, I would like to solve it using…

Naveen Vandanapu

Golang, PyTorch and Deep Learning Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store