Skip to content

Latest commit

 

History

History
26 lines (24 loc) · 321 Bytes

面试题61. 扑克牌中的顺子.md

File metadata and controls

26 lines (24 loc) · 321 Bytes
func isStraight(nums []int) bool {
	num := make([]bool, 14)
	min, max := 14, 0
	for _, v := range nums {
		if num[v] {
			return false
		}
		
		if !num[v] && v != 0 {
			num[v] = true
			if v < min {
				min = v
			}
			if v > max {
				max = v
			}
		}
	}
	if max - min > 4 {
		return false
	}
	return true
}