leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit 90e284b7e569480c147aa97b537f405e3a6da650
parent 52925dd03ae59db213eb728c685491a8b9dea4a4
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Wed,  5 Jul 2023 20:30:13 +0200

Daily Problem

Diffstat:
AProblems/1493.cpp | 13+++++++++++++
MREADME.md | 1+
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/Problems/1493.cpp b/Problems/1493.cpp @@ -0,0 +1,13 @@ +class Solution { +public: + int longestSubarray(const vector<int> &nums) { + int res = 0, left = 0, zero = -1, i; + for (i = 0; i < nums.size(); i++) { + if (nums[i]) continue; + res = max(res, i - left); + left = zero + 1; + zero = i; + } + return max(res, i - left) - 1; + } +}; diff --git a/README.md b/README.md @@ -479,6 +479,7 @@ for solving problems. | 1480 | Easy | [Running Sum of 1d Array](Problems/1480.cpp) | | 1489 | Hard | [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](Problems/1489.cpp) | | 1491 | Easy | [Average Salary Excluding the Minimum and Maximum Salary](Problems/1491.cpp) | +| 1493 | Medium | [Longest Subarray of 1's After Deleting One Element](Problems/1493.cpp) | | 1498 | Medium | [Number of Subsequences That Satisfy the Given Sum Condition](Problems/1498.cpp) | | 1502 | Easy | [Can Make Arithmetic Progression From Sequence](Problems/1502.cpp) | | 1514 | Medium | [Path with Maximum Probability](Problems/1514.cpp) |