Back to articles
Min and Max Elements.

Min and Max Elements.

via Dev.toMubashir

One way is to traverse the array and keep updating the min and max elements . initialize min = arr[0] max = arr[o] traverse the array from index 1 For each element: If element < min → update min If element > max → update max 4.return max and min array 5.Time Complexity: O(n) We traverse the array once Space Complexity: O(1)

Continue reading on Dev.to

Opens in a new tab

Read Full Article
4 views

Related Articles