Remove Element | Leetcode problem 27

preview_player
Показать описание
Remove Element
Leetcode problem number 27
Solution in JAVA

JAVA interview programming playlist:

#java #interviewquestions #leetcode
Рекомендации по теме
Комментарии
Автор

Very nice explanation, after watching 5 videos finally I understood here.

varshapriyadarshini
Автор

thanks mam !that was a excellent solution....i am happy to learn this approach as it was small and effecient

_NITESHMOTIVATION
Автор

simplest way to explain, love your voice , thanks for this amazing content

rinkuchoudhary
Автор

Many people solve this problem by swapping

Something like this

public int removeElement(int[] nums, int val)
{
int l = 0;
int r = nums.length - 1;
while (l <= r) {

if (nums[l] == val) {
int t = nums[l];
nums[l] = nums[r];
nums[r] = t;
r--;

} else {
l++;
}

}

return l;
}


But it is crisp and short

umeshnaik
Автор

But in this question saying that we do not have to use any extra space right?

NikCoder
Автор

this is only the first part of the quetion the other is missing

AmadYT
Автор

How count value returning new array as output i dont understand explain

sravanokumar
Автор

Well this solution is good in its place, what if the question considers to be having an impact with moving the other digits to the end ...that would be more interesting

Saurabh-febg
Автор

From the question, I can see that we should not use another array that very much increases the space complexity and it defeats the whole purpose of two pointer concept

mohanant
Автор

Hi mam! you using for loop .by using that time complexity o(n)if there (N) no of arr, what is the best method to use under the time complexity

prakashradhakrishnan
Автор

but the question says you have to do in-place.

thelazycat
Автор

It will not work because extra space is allocted

brahmithegod
join shbcf.ru