Golang | Leetcode Golang题解之第414题第三大的数
题目:
题解:
func thirdMax(nums []int) int {var a, b, c *intfor _, num := range nums {num := numif a == nil || num > *a {a, b, c = &num, a, b} else if *a > num && (b == nil || num > *b) {b, c = &num, b} else if b != nil && *b > num && (c == nil || num > *c) {c = &num}}if c == nil {return *a}return *c
}