Home Tags Posts tagged with "Leetcode"
Tag:

# Leetcode

• Arrays

## [Leetcode] – Maximum Product Subarray Solution

In this blog post, we’ll explore the “Maximum Product Subarray” problem, where our task is to find the contiguous subarray within an array that yields the maximum product. We’ll discuss the problem statement in detail and explore two approaches: the brute force solution and an optimized solution using dynamic programming techniques.

• Strings

## [Leetcode] – Longest Common Prefix Solution

Given some input strings, we need to find the longest common prefix or the longest starting sequence of characters that is common

• Arrays

## [Leetcode] – Move zeroes Solution

Given an array of positive integers with some zeroes. You need to move all the zeroes to the end without changing the relative order of non-zero elements. A unique solution makes this problem really easy to understand.

• Arrays

## [Leetcode] – Search Insert Position Solution

Binary Search is a fabulous concept that can be used to narrow down the search range. One such problem on LeetCode explores this domain where you need to find the correct position to insert the element in a sorted array

• Arrays

## [Leetcode] – Numbers Smaller than current

Small problems like these often become a part of larger complex problems. You are given an array and for each integer you need to find out the number of smaller numbers than itself. One technique is to compare each element with every other element. Another efficient approach would be to use the counting sort approach.

• Arrays

## [Leetcode] – Number of Good Pairs Solution

Always make sure that we understand the problem statement first. There is an array of integers nums and we need to determine the number of good pairs. A pair (i , j ) is said to be good, if nums[i] == nums[j] and i < j. We need to determine how many pairs can we form that hold this condition. Let us look at some sample test cases: Input: nums = [ 1 , 2 , 3 , 1 , 1 , 3 ]Output: 4Explanation:There are 4 good pairs. (0 …

• Arrays

## [Leetcode] – First and Last Index Sorted Array Solution

Given a sorted array and a target element, find its first and last index.

• Arrays

## [Leetcode] : Find All Duplicates in an Array Solution

Given an array of integers, find the elements that appear twice. The main challenge of this problem is to solve it without using any extra space. You need to find a way to mark the elements that are already encountered. Once such way would be to make the elements negative. This post gives you 2 different solutions a video explanation.

• Strings

## [Leetcode] – Group Anagrams Solution

Given an array of strings, group all the anagrams together. This post explores 2 methods to solve this problem. You can create groups by sorting, or by categorizing using the frequency of characters.

• Arrays