Leetcode-Top -150-Interview-Question -Day -1: Array
Question 1: 88. Merge Sorted Array
Problem Statement:
In this question we are given two sorted arrays nums1 and nums2 of sizes m and n, respectively. We need to merge these two arrays into a single sorted array, and the result should be stored inside nums1. Since nums1 is of size m+n.
CODE:
COMPLEXITY:
Time complexity: O(n);
Space Complexity: O(1);
QUESTION 2 : 27. Remove Element
INTUITION:
The intuition behind this solution is to iterate through the array and keep track of two pointers: idx and i. The idx pointer represents the position where the next non-target element should be placed, while the i pointer iterates through the array elements. By overwriting the target elements with non-target elements, the solution effectively removes all occurrences of the target value from the array.
CODE:
COMPLEXITY:
Time complexity: O(n);
Space Complexity: O(1);
HOPE YOU LIKE MY APPROACHES!!!
THANKYOU!!!