My Approach:
Instead of sorting the array (which takes more time), I decided to scan the array only once.
Steps:
Step-1:First I take the first element as minimum and maximum
Step-2:Then traverse the array from second element
Step-3:Then Compare each element with min and max
Step-4:Then update the min and max variable based the elements
Step-5:Then Return min and max
Method Used:
1.ArrayList
2.for loop to traverse the array because I know the boundary value
3.get() to access values
4.set() to update values

Top comments (0)