• 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

  • Best Time to Buy and Sell Stock

    LeetCode#121. Best Time to Buy and Sell Stock Problem Statement You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction….

  • Increasing Triplet Subsequence

    LeetCode#334. Increasing Triplet Subsequence Problem Statement Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false. Example 1 Input: nums = [1,2,3,4,5] Output: true Explanation: Any triplet where i < j < k is valid. Example 2…

  • Stack using Array

    Stack using Array Golang code for Stack using Array Variations of usage of type struct When to Use Value Receiver (Pass-by-Value) You can and should use pass-by-value in certain cases, especially when: When to Use Pointer Receiver (Pass-by-Pointer) You should use pass-by-pointer when: You need to modify the original struct: If the method changes the…

  • Missing Number

    Leetcode#268 Problem Statement Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1 Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the…

  • Dynamic Programming (DP)

    Dynamic programming (DP) is a popular topic in coding interviews, especially with companies like Google. Here’s a set of 5 dynamic programming questions categorized into easy, medium, and hard levels, tailored for Go programming. 1. Fibonacci Sequence Level: EasyProblem:Write a function to calculate the nth Fibonacci number using dynamic programming. The Fibonacci sequence is defined…

  • Trapping Rain Water

    Leetcode#42 Problem Statement Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section)…