Reverse Nodes in k-Group

Leetcode#25 Reverse Nodes in k-GroupLogicGolang SolutionOutput Reverse Nodes in k-Group Logic Use mind to make it simple Try to reuse existing code Calculate number of iterations required with given total…

Sorting

Quick Sort Quick Sort package main import "fmt" // QuickSort function sorts an array in-place using left and right pointers func QuickSort(arr []int, left, right int) { if left <…

Synchronisation in Golang

MutexOutputChannel Workers Processing Tasks (Incrementing Numbers)OutputNegative cases Mutex package main import ( "fmt" "sync" ) type Counter struct { mu sync.Mutex count int } func (c *Counter) IncrementCount() { c.mu.Lock()…

For loop Patterns

Pattern 1 Iterating over array n timesPattern 2 Printing staircase patternsPattern 3 Printing all SubarrayPattern 4 Iterating over all Subarray and printing Sum, lengths Pattern 1 Iterating over array n…

Max Consecutive Ones III

Leetcode#1004 Max Consecutive Ones IIIProblem StatementGolang SolutionOutput Max Consecutive Ones III Problem Statement Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can…

Search in Rotated Sorted Array

Leetcode#33 Search in Rotated Sorted ArrayProblem StatementLogicGolang SolutionOutput Search in Rotated Sorted Array Problem Statement There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your…