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