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,…
Tag: go
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…
Wildcard matching or regex matching program in Go (Golang)
Overview We are given an input regex and an input string. Regex can have two special characters Star Sign ‘*’ – the star matches zero or more characters. Question Mark ‘?’ –…
Find the first and last position of a target element in a sorted array in Go (Golang)
Overview The objective is to find the first and last position of an element in a sorted array. Eg Strategy is to Do a binary search in the array and find the…
Sort a string in Go (Golang)
Overview In Golang string is a sequence of bytes. A string literal actually represents a UTF-8 sequence of bytes. In UTF-8, ASCII characters are single-byte corresponding to the first 128 Unicode characters. All…
Search in a sorted and pivoted array in Go (Golang)
Overview We have an input array that is sorted but is pivoted at a certain index. For example, consider below array It has been rotated and pivoted at index 3 Given a…
Find the pivot index in a sorted and pivoted array in Go (Golang)
Overview We have an input array that is sorted but is pivoted at a certain index. For example, consider below array It has been rotated and pivoted at index 3 The objective…
Evaluation of Postfix Expression in Go (Golang)
Evaluation of Postfix Expression In this tutorial, we will evaluate a postfix expression. Algorithm: Scan postfix expression from left to right. If the current scanned character is an operand, push it in…