A trick when searching for max and min values is to initialize the variables with extreme values. Make min the largest possible value and max the smallest.