The Prefix Sum algorithm is a technique primarily used to efficiently calculate the sum of elements in a given range (i.e., sum of elements from index i to j) in an array….
Category: Golang
Sliding Window Algorithms
The sliding window technique is a method used in algorithm design to efficiently solve problems that involve contiguous subarrays or substrings of a given size or condition. It’s particularly useful when you…
[Draft]Algorithms that You Have to Know[in go]
Make duplicate to zero Bubble Sorting
Palindrome Problems Summary
Palindrome problems 1. Basic algorithm to check palindrome This section presents methods for checking if a string is a palindrome: 1.1 Check if a substring is palindrome at i and expand it….
Combinational Sum
Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the…
List library in golang
In Go (Golang), list.New() is used to create a new doubly linked list. The container/list package provides the implementation for this data structure. A doubly linked list allows you to store a…
slices.Sort in Go lang
The slices.Sort function in Go is used for sorting slices. It was introduced in Go 1.18 as part of the new generics features, providing a more straightforward and type-safe way to sort…
Check data type in golang
In Go (Golang), checking the data type of a variable can be done in several ways, depending on the context and what information you need about the data type. Here are some…
Decode JSON in Golang
In Go (Golang), there are several ways to decode JSON, each suited for different scenarios. Here’s a list of common methods along with their typical use cases: 1. json.Unmarshal json.Unmarshal: This is…
Find the first and last occurrence in an array
To find the first occurrence of a target value in a sorted array using binary search, the algorithm needs to be slightly modified from the standard binary search. The goal is to…