The reason for taking -1 is that it should not conflict with any other number in array. If you take any other number and if that number is present in array the output will be wrong so if it is integer array any negative value or value that is not going to be present in array will work
Hi.. Space complexity is an issue here, if you use multiple loops approach
finally understood thank you
super explained thank you
thanks mam..understood finally
Understood. Thanks.
Finally Im cool with This explanation
best of all ty.
Life saver
how to solve this que with 0(n)
Awesome
Madam element tesukoni explain cheyochuga madam ex array [I] = 2 then process going like that
thank you
❤️❤️
Why are u using new array?
Getting error with this code...with ArrayIndexoutOfBounds...
it usually happens when you access element greater than array length(keep in mind array indexing starts from 0 to n-1)
can we put some other value instead of -1 in (int visited) please tell if possible
The reason for taking -1 is that it should not conflict with any other number in array. If you take any other number and if that number is present in array the output will be wrong so if it is integer array any negative value or value that is not going to be present in array will work
@@CodeBode so we can take -2 also?
Yes
How to do this same program using inheritance
@@shivam7164 The idea to take any marker. The value that you know won't occur in array. It can be -10, it can be 100. Etc.
This is not efficient method as it's gets O(n^2)time complexity
True this is not the most efficient just one of the way to find the frequency. Thanks for the comment. Keep learning!
@@CodeBode mam please do the same program with any other method
Not the most efficient way but I don't see your example posted.
copy paste from Javatpoint :p :p