Overview The objective is to get the height of a binary tree. For example, if let’s say we have below binary tree Then the height of the binary tree is 3 here….
Tag: golang
Level Order Traversal of a binary tree in Go (Golang)
Overview The objective is to print the binary tree level by level. For example, if let’s say we have below binary tree Here we have Node 1 on level 1 Node 2…
Check if a given tree is a Binary Search Tree in Go (Golang)
Overview We can use the below strategy to know if a given tree is a BST. For a given current node, if the left and right subtree are BST The maximum value…
Interleaving String Program in Go (Golang)
Overview Three strings are given s1, s2, s3. Find if string s3 is interleaving of string. s3 will be an interleaving of string s1 and s2 if the below condition is satisfied…
Sort an array of 0, 1, and 2 in Go (Golang)
Overview The objective is to sort an array of 0,1 and 2 with all 0’s at the start, all 1’s in the middle, and all 2’s in the end. The Space Complexity…
Merge overlapping intervals in Go (Golang)
Overview Given an array of intervals where each interval has a start time and end time, merge the overlapping intervals. Two intervals are said to be overlapping if the end time of…
Group anagrams together program in Go (Golang)
Overview Given an array of strings, write a program to group all anagrams together. From Wikipedia An anagram is a word or phrase formed by rearranging the letters of a different word or phrase,…
Spiral Matrix Problem in Go (Golang)
Overview The objective is to print a matrix in a spiral format. Eg Input Output Program Below is the program for the same Output Note: Check out our Golang Advanced Tutorial. The…
Rotate a symmetric matrix or an image in place in a clockwise direction in Go (Golang)
Overview Given an image represented in the form of a matrix, rotate this matrix or image in a clockwise direction. For eg Input: Output: Idea is to iterate over all the borders…
Trapping rainwater problem in Go (Golang)
Overview There is a set of bars each of 1 unit width but different heights placed alongside. The height of the bars is represented using an array The array represents that The…