It isn’t really any easier if they are next to each other and if you don’t flatten first they will still be nested JS will see them as arrays not numbers to sort it will sort the parent arrays and the things within them but it won’t directly yield the results you’re looking for. You’ll still need to flatten it too lol
you could put checking for duplication as part of your loop instead of doing it after if you wanted to though!
Checking an unsorted array for duplication requires keeping track of elements you've seen before though, whereas if they're next to each other you can just walk through the array and drop elements that are the same as the previous one. For longer arrays this can be a considerable memory improvement.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It isn’t really any easier if they are next to each other and if you don’t flatten first they will still be nested JS will see them as arrays not numbers to sort it will sort the parent arrays and the things within them but it won’t directly yield the results you’re looking for. You’ll still need to flatten it too lol
you could put checking for duplication as part of your loop instead of doing it after if you wanted to though!
Checking an unsorted array for duplication requires keeping track of elements you've seen before though, whereas if they're next to each other you can just walk through the array and drop elements that are the same as the previous one. For longer arrays this can be a considerable memory improvement.