• 8 Patterns Review For Successful Coding Interview

    8 Patterns Review For Successful Coding Interview This is nothing but quick 5 min revision before going to interview. Visit https: https://codeandalgo.com for more such contents

  • Golang Top 10 Features

    Golang Top 10 Features 1. Tuple Assignment in Go Tuple assignment in Go is generally faster because it is a single, atomic operation that the Go compiler can optimize effectively. Go has several features and idioms similar to tuple assignment that help write concise and efficient code. Here are some notable ones: 2. Multiple Return…

  • Reverse Vowels of a String

    Problem Statement LeetCode#345 Given a string s, reverse only all the vowels in the string and return it. The vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’, and they can appear in both lower and upper cases, more than once. Example 1: Input: s = “hello” Output: “holle” Example 2: Input: s = “leetcode” Output: “leotcede” Constraints: Golang Code Reverse Vowels…

  • Can Place Flowers

    Problem Statement You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an integer array flowerbed containing 0‘s and 1‘s, where 0 means empty and 1 means not empty, and an integer n, return true if n new flowers can be planted in the flowerbed without violating the no-adjacent-flowers rule and false otherwise. Example 1: Input: flowerbed =…

  • Greatest Common Divisor of Strings

    Problem Statement Greatest Common Divisor of Strings For two strings s and t, we say “t divides s” if and only if s = t + t + t + … + t + t (i.e., t is concatenated with itself one or more times). Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. Example 1: Input: str1 = “ABCABC”, str2 = “ABC” Output: “ABC”…

  • Primitives

    Array Integer Array Operations Comparison Array Operations Comparison Operation Java Go (Golang) Python 3 Array Declaration int[] arr; var arr [size]int arr = [] Array Initialization with Length int[] arr = new int[5]; var arr = make([]int, 5) arr = [None]*5 Array Initialization without Length int[] arr = {1, 2, 3}; arr := []int{1, 2,…

  • Merge Strings Alternately

    LeetCode #1768 Problem statement You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string. Return the merged string. Example 1: Input: word1 = “abc”, word2 = “pqr” Output: “apbqcr” Explanation: The merged…