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.
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.
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.
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
Input: nums = [2, 1, 0, 3, 2, 3]
Explanation: The longest increasing subsequence is [1, 2, 3], therefore the length is 3Note that there can be multiple longest increasing subsequences of same length
This is a good problem to practice recursion and Dynamic Programming. …
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)
Input: nums = [1,1,1,2,2,3], k = 2
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].
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…
Golang, PyTorch and Deep Learning Enthusiast