Back

Arrays & Basics (Easy) / Find Maximum Element

00:00
1/40

Find Maximum Element

Given an array of integers, find the largest element present in the array.

  • 1

    Initialize a variable (e.g., max_val) with the first element of the array.

  • 2

    Iterate through the array starting from the second element.

  • 3

    In each step, compare the current element with max_val.

  • 4

    If the current element is greater, update max_val.

  • 5

    After checking all elements, return the value stored in max_val.

PYTHON PLAYGROUND
PYTHON PLAYGROUND
⏳ Loading editor…