算法(132模式)

 

 

func find132pattern(nums []int) bool {
    result := false
    if (len(nums) == 0) {
        return false
    }
    min := nums[0]
    // 思路2: 找一个中间值,中间值前面的数字小
    for i := 1; i < len(nums); i ++ {
        for j := i + 1; j < len(nums); j ++ {
            if (nums[i] > nums[j] && nums[j] > min) {
                result = true
                break
            }
        }
        if (min > nums[i]) {
            min = nums[i];
        }
    }
    return result
}

算法(132模式)

 

相关文章:

  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-08-17
  • 2021-06-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-12-14
  • 2022-02-11
相关资源
相似解决方案