DEV Community

Saranya R
Saranya R

Posted on

Find the Maximum and Minimum Element in the Array

Approach explanation ( •̀ ω •́ )✧

  1. I started by setting both min_val and max_val to the first element of the array.
  2. I went through each element in the array.
  3. If I found a smaller element, updated min_val.
  4. If I found a larger element, updated max_val.
  5. At the end, I had both the minimum and maximum values in one pass.

Methods used: (〜 ̄▽ ̄)〜

  • Single traversal method
  • Comparison updates

Top comments (0)