Array - 34: Remove all duplicates from Sorted Array

preview_player
Показать описание
Solution:
- We'll iterate the all element from 1st index
- We'll take 'start' variable, where we'll fill value if it's new element (if a[i] != a[i-1])
- At last we'll return 'start' as anaswer as till now we've all unique elements & we've pul all unique elements at the start of array

Time Complexity: O(n)
Space Complexity: O(1)

Do Watch video for more info

CHECK OUT CODING SIMPLIFIED

★☆★ VIEW THE BLOG POST: ★☆★

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

★☆★ Send us mail at: ★☆★
Рекомендации по теме
Комментарии
Автор

thanks bro .. I almost stucked here for two days

StudyMateclass
Автор

Sir aapka explanation acha hai, wrna aaj kl koi bhi YouTube pe channel banake code rattke baithe hai

aesthetic
Автор

just found ur channel, great programming content.

pranav
Автор

great explanation! one small correction ..ig after for loop it should be start - - ; to get correct unique element size

tilakrajrao
Автор

Thanks sir I was stuck in this problem

youtbeutube
Автор

Well explanation👍. Is it really removing all duplicates from array? I think no. Because the remaining values still spoils the array with duplicates. Can we keep it in separate array and assign it back to the old array or just remove the remaining elements from start. Then we could say the array has only unique values. What about your opinion on this?

shanp