Overview Given a linked list and a number k reverse nodes of the linked list in groups of k. For eg If the length of the last group of the linked is…
Tag: golang
Append or Add one slice to another slice in Go (Golang)
Overview It is also possible to append one slice to another slice. Below is the format for that. Notice ‘…’ after the second slice. ‘…’ is the operator which means that the argument is a variadic…
Sort a part of the slice in Go (Golang)
Overview sort.Slice package of golang can be used to sort a full slice or a part of the sliceFull slice sorting in asc order Output Full slice sorting in desc order Output…
Reverse a linked list in Go (Golang)
Overview The objective is to reverse a given linked list. Eg Program Below is a program for the same Output Note: Check out our Golang Advanced Tutorial. The tutorials in this series…
Check valid parenthesis in Go (Golang)
Overview There is an input string that only contains below characters ( ) { } [ ] The objective is to check if the input string has valid parentheses. A parenthesis is…
Generate valid parentheses in Go (Golang)
Overview Given an int n which means the number of pairs of parentheses, generate all valid well-formed parenthesis. For eg ProgramIdea is to use two integers open – It represents the number…
Find the sum which is closest to a target number using three numbers in an array or 3Sum closest problem in Go (Golang)
Overview The objective is to find the sum using three triplets in the given array such that the sum is closest to a given target sum. For Program Below is the program…
Find all triplets in an array that adds to a target number in Go (Golang)
Overview Let’s say the input is Then the answer would be We can use a hash for the solution. It is based upon the idea that If two of the numbers are…
Find all triplets in an array that adds to a zero in Go (Golang)
Overview Let’s say the input is Then the answer would be We can use a hash for the solution. It is based upon the idea that If two of the numbers are…
Implement your own Atoi function in Go (Golang)
Overview Atoi function converts a given string into its number representation. For eg Program Below is the program for the same. Output