Given an integer array nums, find and return the maximum element in the array.
You must solve it without using any built-in max functions.
Input: An integer array nums of length n.
Output: A single integer — the maximum element.
Input: [3,1,4,1,5,9,2,6]
Output: 9
Explanation: Start max=3. Check 4>3 → max=4. Check 5>4 → max=5. Check 9>5 → max=9. No bigger found. Return 9.Input: [-5,-1,-3,-2]
Output: -1
Explanation: Start max=-5. Check -1>-5 → max=-1. -3 and -2 are less than -1. Return -1.Input: [42]
Output: 42
Explanation: Only one element. It is trivially the maximum. Return 42.1 <= nums.length <= 10^5-10^9 <= nums[i] <= 10^9