DSA-solutions-the10xacademy / JavaScript-DSA-Solutions

1 stars 1 forks source link

Arrays - Number Occurring Maximum Times #546

Open SaivijayK opened 2 years ago

SaivijayK commented 2 years ago

Checklist

SaivijayK commented 2 years ago

can we change line 18 where element of array is compared with undefined?

SaivijayK commented 2 years ago

@chhaviteotia in this problem we are checking whether the number is occurring first time or its already occurred, so for solving that kind of problem, we need to use undefined

SaivijayK commented 2 years ago

@LVSsandeepVarma yes i can write the code in O(1) space, but this question belongs to topic ARRAY, so that's the reason why, i have used Array in the code, do you want me to do in O(1) space, without using any array?

LVSsandeepVarma commented 2 years ago

@LVSsandeepVarma yes i can write the code in O(1) space, but this question belongs to topic ARRAY, so that's the reason why, i have used Array in the code, do you want me to do in O(1) space, without using any array?

@SaivijayK ok in that case then it's better with array only