Overview A simple regex can be used to check if a string contains single or multiple white spaces in Go. Here is the program for the same Program Output Note: Check out…
Tag: golang
Repeat a string multiple times in Go (Golang)
Overview strings.Repeat method can be used to repeat a string multiple times in Go (Golang) Here is the link to this function in the Go strings package https://pkg.go.dev/strings#Repeat Here is the signature…
Remove Linked List Elements Program in Go (Golang)
Overview Given a linked list and a value, delete all nodes from the linked list whose value is equal to the given value. Example 1 Example 2 Program Below is the program…
Recover Binary Search Tree Program in Go (Golang)
Overview The root of a binary search tree is given. Two nodes of the binary search tree have been swapped. We need to fix the binary tree and recover the original structure…
Program for ugly number 2 in Go (Golang)
Overview An ugly number is a number whose prime factors are limited to 2,3 and 5. We have already seen a program where given a number n returns true if it is…
Binary Tree Maximum Path Sum Program in Go (Golang)
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…
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…