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

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

Technosage

1 год назад

22,942 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Navin Venkat
Navin Venkat - 14.11.2023 14:52

Mam can you give me the solution in C language pls!

Ответить
Cristiano Ronaldo
Cristiano Ronaldo - 07.10.2023 12:21

Excellent

Ответить
Subhashree Sahoo
Subhashree Sahoo - 23.09.2023 12:33

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<Integer> 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 ?

Ответить
Esha Singh
Esha Singh - 14.09.2023 22:34

Well presented

Ответить
Muthumanipandi M
Muthumanipandi M - 09.07.2023 12:30

@6.42 Why the last element won't be the duplicate?

Ответить
Vamshi Sundupalle
Vamshi Sundupalle - 19.06.2023 13:06

can u continue the series mam pls
ur approach is so good

Ответить
Suraj Kumar
Suraj Kumar - 14.06.2023 10:44

nice explanation dude☺

Ответить
Kunal Dixit
Kunal Dixit - 03.06.2023 22:36

thanks mam

Ответить
Pranjali Patil
Pranjali Patil - 24.05.2023 21:18

Thank you mam

Ответить
Ajeet Tiwari
Ajeet Tiwari - 21.05.2023 00:15

mam pls continue this interview series thanks you mam🤩🤩🤩🤩

Ответить