Overview A binary tree is given. The objective is to find the maximum Path Sum in that binary tree. A path in a binary tree is a sequence of nodes that are connected…
Tag: go
Sort characters by frequency in Go (Golang)
Overview An input string is given. The objective is to sort the string based on frequency. We have to sort based on decreasing order of the frequency of characters. Let’s understand it…
Check If N and Its Double Exist in Go (Golang)
Overview An array is given. The objective is to find if there exists any number for which it’s double also exists. Example 1 Example 2 The idea is to use a map…
Program for Pascal’s Triangle in Go (Golang)
Overview The objective is to find the print n number of rows of Pascal’s triangle. The number n is given as an input to the program Example 1 Example 2 Refer to…
Longest Consecutive Sequence Program in Go (Golang)
Overview An integer array is given. Find the length of the longest consecutive sequence in it. Let’s see an example to understand it Example 1 Example 2 The naive idea is to…
Print all Binary Tree Paths in Go (Golang)
Overview The root of a tree is given. The objective is to print all the tree paths starting with the root. Example Output: Program Below is the program for the same Output:…
Determine Whether Matrix Can Be Obtained By Rotation in Go (Golang)
Overview Two n*n matrices are given source and target. We have to determine whether the source matrix can be converted to the target matrix by doing 90-degree rotations any number of times…
Detonate the maximum bombs program in Go (Golang)
Overview A 2d array is given where each entry in an array has three values i- Denotes the x coordinates of the bomb j – Denotes the y coordinates of the bomb…
Rotting Oranges Program in Go (Golang)
Overview An m*n matrix is given where each entry contains three values 0 – Denotes that entry is empty 1 – Denotes that entry contains fresh orange 2 – Denotes that the…
Count unreachable pair of nodes in an undirected graph in Go (Golang)
Overview An integer n is given. There are n nodes numbered 0 to n-1. A 2D integer array edges is also given where edges[i] = [ai, bi] means that there is an…