32. Find Maximum Element Using Pointer Walk

You are given an array of integers and its size n.
Using only pointer arithmetic:

  • Traverse the array
  • Find and print the maximum element in the array.

❌ Do not use array indexing like arr[I].
✅ Only use pointer movements and dereferencing.
 

Example-1

Input: n = 5, arr = [10 25 5 30 15]
Output: 30


Example-2

Input: n = 4, arr = [1 1 1 1]
Output: 1


Example-3

Input: n = 3, arr = [-5 -2 -9]
Output: -2


 

Loading...

Input

5 10 25 5 30 15

Expected Output

30