Skip to content Navigation Menu Toggle navigation Sign in Appearance settings PlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub Copilot appDirect agents from issue to mergeMCP RegistryNewIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersView all resourcesOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityAcceleratorGitHub StarsArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricing Search or jump to... Search code, repositories, users, issues, pull requests... Search Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. Include my email address so I can be contacted Saved searches Use saved searches to filter your results more quickly Name Query To see all available qualifiers, see our documentation. Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} anishLearnsToCode / leetcode-algorithms Public Notifications You must be signed in to change notification settings Fork 17 Star 97 Code Issues 0 Pull requests 0 Discussions Actions Projects Security and quality 0 Insights Additional navigation options Code Issues Pull requests Discussions Actions Projects Security and quality Insights FilesExpand file tree masterBreadcrumbsleetcode-algorithms/python/non_decreasing_array.pyCopy pathBlameMore file actionsBlameMore file actions Latest commit HistoryHistoryHistory13 lines (11 loc) · 503 Bytes masterBreadcrumbsleetcode-algorithms/python/non_decreasing_array.pyCopy pathTopFile metadata and controlsCodeBlame13 lines (11 loc) · 503 BytesRawCopy raw fileDownload raw fileOpen symbols panelEdit and raw actions12345678910111213from typing import List class Solution: def checkPossibility(self, nums: List[int]) -> bool: handled_decreasing = False for index in range(len(nums) - 1): if nums[index] > nums[index + 1]: if handled_decreasing: return False handled_decreasing = True if index - 1 >= 0 and nums[index - 1] > nums[index + 1] and index + 2 < len(nums) and nums[index] > nums[index + 2]: return False return True You can’t perform that action at this time.