Largest and Smallest number in array

when comparing the number while iterating through the array,
what is the difference between setting the largest and smallest number to the first number of array vs plus infinity and negative infinity?

hello @ryoojw94

both are correct, infact initilaising it with first array elemnt is better approach. as it is not depending on any range.

when we are initilaising variable with INT_MAX then we are assuming that value cant be greater than INT_MAX .
whereas initialisation with first value of array is assumption free and more generic

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.