Remove Duplicates from Sorted Array | Leetcode 26 | Top 150 interview question series

  Рет қаралды 28,523

Technosage

Technosage

Жыл бұрын

Top 150 interview question series
Remove Duplicates from Sorted Array
Leetcode problem number 26
JAVA interview programming playlist:
• Interview Programming ...
Git Repo:
github.com/Technosagelearning...

Пікірлер: 27
@user-jj9rk4en9i
@user-jj9rk4en9i 6 күн бұрын
great explanation simple approach for those in new in dsa
@saarza9991
@saarza9991 4 ай бұрын
1) HashSet could be used 2) the condition for upper bound of i in if block was unnecessary. You could've said: i
@narendrabudaniya4353
@narendrabudaniya4353 28 күн бұрын
mam your code is left the last element always so return count is always less one here is the write code int pointer = 0; for (int i=0; i
@RajYadav-yh7vv
@RajYadav-yh7vv 4 ай бұрын
why to use (nums.length-1) in if condition. its working without this also. Submitted in leetcode and accepted successfully working code: var removeDuplicates = function (nums) { let count = 0; for (let i = 0; i < nums.length; i++) { if (nums[i] === nums[i + 1]) { continue; } else { nums[count] = nums[i]; count++; } } return count; };
@ajeettiwari8622
@ajeettiwari8622 Жыл бұрын
mam pls continue this interview series thanks you mam🤩🤩🤩🤩
@SurajKumar-mq9ww
@SurajKumar-mq9ww Жыл бұрын
nice explanation dude☺
@eshasingh2847
@eshasingh2847 10 ай бұрын
Well presented
@pranjalipatil532
@pranjalipatil532 Жыл бұрын
Thank you mam
@ronaldo76544
@ronaldo76544 9 ай бұрын
Excellent
@subhashreesahoo5760
@subhashreesahoo5760 10 ай бұрын
Hi , Could you please help me in understanding this question , because I have done this problem in other way , I am getting the desired result in IDE but in leetcode it is failing . Please have a look on below approach: Set set=Arrays.stream(nums).boxed().collect(Collectors.toCollection(LinkedHashSet::new)); int[] expectedNums=new int[set.size()]; int index=0; for(int i:set){ expectedNums[index]=i; index++; } System.out.println(Arrays.toString(expectedNums)); System.out.println(expectedNums.length); I can return expectedNums.length at the end . But this solution is not accepted , why ?
@thevichusvlog5809
@thevichusvlog5809 8 ай бұрын
hey subha , I also went for the same approach and faced same issue. Just read the test case how they're validating our code. They're not only validating our final distinct array size they are also validating whether final values in nums[] arrays is distinct or not. public int removeDuplicates(int[] nums) { int i=0; List distinctNums = Arrays.stream(nums).distinct() .boxed().collect(Collectors.toList()); for(int num:distinctNums){ nums[i] = num; i++; } return distinctNums.size(); } before returning the distinct array size please do assign the distinct value to same nums[] array back. Else test case validation will be failed in back-end.
@kunaldixit2566
@kunaldixit2566 Жыл бұрын
thanks mam
@imvishu09
@imvishu09 Ай бұрын
please explain this -> nums[count] = nums[i];
@vamshisundupalle6141
@vamshisundupalle6141 Жыл бұрын
can u continue the series mam pls ur approach is so good
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Sure..Will start uploading the videos soon
@pratiknandurkar7925
@pratiknandurkar7925 3 ай бұрын
❤❤
@user-lk8zi8qh3k
@user-lk8zi8qh3k Жыл бұрын
@6.42 Why the last element won't be the duplicate?
@TechnosageLearning
@TechnosageLearning Жыл бұрын
Because there is no element after the last element..If it's a duplicate then second last and last element would be same..If we have already checked for second last element..No need to check last element since it's a sorted array
@ShivaKumar-vu5sg
@ShivaKumar-vu5sg 8 ай бұрын
why are you writing i
@prangyajena3082
@prangyajena3082 6 ай бұрын
Tried but it’s breaking. The loop should run till nums.length where on the last element if it’s not meeting criteria count should increase
@Sainathbabu840
@Sainathbabu840 5 ай бұрын
Watch 5:20
@musamehdiyevv
@musamehdiyevv Ай бұрын
class Solution { public int removeDuplicates(int[] nums) { int k = 1; for (int i = 1; i < nums.length; i++) { if (nums[i] != nums[k-1]) { nums[k] = nums[i]; k++; } } return k; } }
@navinvenkat3404
@navinvenkat3404 8 ай бұрын
Mam can you give me the solution in C language pls!
@Jack-ss4re
@Jack-ss4re 6 ай бұрын
Almost same thing, you can ask chatgpt to convert it to C tho
@dipeshraj4914
@dipeshraj4914 2 ай бұрын
Mam,can u provide these 150 questions list...
@amanraj5116
@amanraj5116 2 ай бұрын
It is already listed on Leetcode websites as 150 interview questions
@ne_aqqumka
@ne_aqqumka 4 ай бұрын
и чё
Remove Element | Leetcode problem 27
6:30
Technosage
Рет қаралды 29 М.
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 37 МЛН
УГАДАЙ ГДЕ ПРАВИЛЬНЫЙ ЦВЕТ?😱
00:14
МЯТНАЯ ФАНТА
Рет қаралды 2,8 МЛН
Beautiful gymnastics 😍☺️
00:15
Lexa_Merin
Рет қаралды 13 МЛН
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 52 МЛН
for Loop vs. while Loop in Python
8:45
Neso Academy
Рет қаралды 26 М.
Remove Duplicates from Sorted Array II | Leetcode 80 | Array
11:29
Ayushi Sharma
Рет қаралды 35 М.
Reverse Integer | LeetCode problem 7
7:00
Technosage
Рет қаралды 17 М.
Cisco Store at Cisco Live 2021 Overview
0:43
Cisco Store Tech Lab
Рет қаралды 556
Ugly Number (Leetcode 263) in Telugu
2:51
Coding Interview Preparation
Рет қаралды 157
Remove Duplicates from Sorted Array
5:41
Kevin Naughton Jr.
Рет қаралды 74 М.
Remove Duplicates from Sorted Array - Leetcode 26 - Python
10:38
Maximum Subarray | Kadane's Algorithm | Leetcode 53
7:20
Technosage
Рет қаралды 7 М.
Сколько реально стоит ПК Величайшего?
0:37
iPhone socket cleaning #Fixit
0:30
Tamar DB (mt)
Рет қаралды 14 МЛН
iPhone 15 Pro в реальной жизни
24:07
HUDAKOV
Рет қаралды 411 М.
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Tynalieff Shorts
Рет қаралды 1,2 МЛН
Look, this is the 97th generation of the phone?
0:13
Edcers
Рет қаралды 4 МЛН
СТРАШНЫЙ ВИРУС НА МАКБУК
0:39
Кринжовый чел
Рет қаралды 1,4 МЛН