Day 2 : Coding Challenge
Problem - Given an integer array nums and an integer val, remove all ccurrences 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:
Solution -
Optimized Solution -
The Problem is easy we have to return the k elements and the array consisting of elements which are not equal to val.
Here we will use the variable to insert the elements which are not equal to val at the front of array simultaneously.
Time Complexity - O(N)
Space Complexity - O(1)
#Codingchallenge #problemsolvingskills #problemsolving #codeforgood #60daysofchallenge #60dayscode #consistency #dsaforproblemsolving