Find the second largest number in an array.
Given a list of integers nums, return the second largest distinct value. Return None when fewer than two distinct values exist. Implement the solution using one pass through the array with constant extra space.
Function signature: def second_largest(nums):. The input is a non-empty list of integers, and the output is an integer or None.
def second_largest(nums):