Can Place Flowers

Problem StatementGolang Code Problem Statement LeetCode #605 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.…

Greatest Common Divisor of Strings

Problem StatementGreatest Common Divisor of StringsLOGICHow the Euclidean Algorithm WorksExample of the Euclidean AlgorithmWhy the Euclidean Algorithm WorksTime Complexity of the Euclidean AlgorithmSummaryJAVA CODEGOLANG CODEExplanationExample RunTime ComplexitySpace ComplexitySummary Problem Statement…

Primitives

ArrayInteger Array Operations ComparisonStringString Operations ComparisonString vs Char Array ComparisonKey Differences in JAVA, GOLANG, Python3 Array Java arrays are of fixed size, and adding an element requires creating a new…

Merge Strings Alternately

LeetCode #1768Problem statementJAVA CODEOptimal Solution 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…

Median of Two Sorted Arrays

LeetCode # 4 Problem statementExampleJAVA CODE Median of Two Sorted ArraysBRUTE FORCE APPROACHLOGICBetter ApproachLOGICOptimal SolutionLogicComplexity 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…

Add to Array-Form of Integer

LeetCode Problem #989 Problem StatementLOGICJAVA CODE Add to Array-Form of IntegerGolang solutionSimilar Question Problem Statement The array-form of an integer num is an array representing its digits in left to right order. For example,…

Two Sum

Problem StatementGolang code for Two sumJAVA CODE TWO SUMVersion-1Version-2 Corrected and optimized LeetCode#1 Problem Statement Given an array of integers nums and an integer target, return indices of the two numbers such that they…

Water Bottles

Problem StatementJAVA CODE Water BottlesBetter Clean Code VersionHINTSimilar Question 1518. Water Bottles Problem Statement There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the…