Day73力扣打卡

打卡记录

在这里插入图片描述


统计移除递增子数组的数目 II(双指针)

链接

class Solution:
    def incremovableSubarrayCount(self, a: List[int]) -> int:
        n = len(a)
        i = 0
        while i < n - 1 and a[i] < a[i + 1]:
            i += 1
        if i == n - 1:  # 每个非空子数组都可以移除
            return n * (n + 1) // 2

        ans = i + 2
        j = n - 1
        while j == n - 1 or a[j] < a[j + 1]:
            while i >= 0 and a[i] >= a[j]:
                i -= 1
            ans += i + 2
            j -= 1
        return ans

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-28 13:06:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-28 13:06:02       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-28 13:06:02       82 阅读
  4. Python语言-面向对象

    2023-12-28 13:06:02       91 阅读

热门阅读

  1. Python实用工具大全

    2023-12-28 13:06:02       54 阅读
  2. MySQL ORDER BY(排序) 语句-读取的数据进行排序

    2023-12-28 13:06:02       64 阅读
  3. Large Language Model Situational Awareness Based Planning

    2023-12-28 13:06:02       51 阅读
  4. python -- 容器

    2023-12-28 13:06:02       56 阅读
  5. 如何使用GPT4写一篇综述

    2023-12-28 13:06:02       60 阅读
  6. devops使用

    2023-12-28 13:06:02       56 阅读
  7. Ndk编译hevc静态库

    2023-12-28 13:06:02       69 阅读
  8. 2023-12-27 语音转文字的whisper应用部署

    2023-12-28 13:06:02       61 阅读