Leetcode 283 – Move Zeroes | Two Pointer

Move Zeroes

Problem Description: Given an integer array nums, move all 0‘s to the end of it while maintaining the relative order of the non-zero elements. Example 1: Example 2: Constraints: Move Zeroes – LeetCode Solution(s): To move all zeros to the end of an integer array while maintaining the relative order of the non-zero elements, you can follow … Read more

Leetcode 42 – Trapping Rain Water | Two Pointer

Trapping Rain Water

Problem Description: 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 : Example 2: Constraints: Problem Link :Trapping Rain Water – LeetCode Solution(s): Approach 1: Brute Force Solution Java Code: Explanation: 1.Initialization: 2.Main Loop: 3.Finding Maximum Height to the Left: … Read more

Leetcode 88- Merge Sorted Array | Two Pointer

Merge Sorted Array

Merging sorted arrays is a fundamental problem in computer science. The task is to combine two sorted arrays into one sorted array, maintaining the order. The Merge Sorted Array presents this classic problem with a twist — you are asked to merge the arrays in-place. This means that instead of using extra space, you must … Read more

Leetcode 189 – Rotate Array | 3 Approaches

Leetcode 189 - Rotate Array

Problem Description: Given an integer array nums, rotate the array to the right by k steps, where k is non-negative. Example 1: Example 2: Constraints: Problem Link : Rotate Array – LeetCode Solution(s): Approach 1: Using temporary array Java Code: Complexity: Approach 2 : In-Place Java Code : Complexity:

Leetcode 27- Remove Element from Array

Leetcode 27- Remove Element

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things: Custom Judge: The judge will test your … Read more