• 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

  • 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…

  • Median of Two Sorted Arrays

    LeetCode # 4 Problem statement Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example Example 1: Example 2: JAVA CODE Median of Two Sorted Arrays BRUTE FORCE APPROACH LOGIC Better Approach LOGIC Optimal Solution Logic Complexity Visit https: https://codeandalgo.com for more such contents.

  • Maximum Product of Two Elements in an Array

    LeetCode # 1464 LOGIC Time Taken = 37 mins JAVA CODE Maximum Product of Two Elements in an Array Visit https: https://codeandalgo.com for more such contents

  • Add Two Numbers in Linked List format

    LeetCode Problem #2 DO NOT LOSE CONFIDENCE Simple Example Alway try to take simple example SUM of number1 + number 2 = 4321 + 98 = 4419 But EXPECTED answer is NOT 4419 but it is reverse of 4419 i.e. [9, 1, 4, 4] TRICK JAVA CODE Add Two Numbers in Linked List format Visit…