aboutsummaryrefslogtreecommitdiff
path: root/other/longest_subarr_ones.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
committerJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
commita96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch)
treee2a2b3f49f9fb741be81415266ac93e74cff42ec /other/longest_subarr_ones.cpp
parent694ad5ed71edcb1deccab54b72d706b779918276 (diff)
downloadleetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz
leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/longest_subarr_ones.cpp')
-rw-r--r--other/longest_subarr_ones.cpp31
1 files changed, 0 insertions, 31 deletions
diff --git a/other/longest_subarr_ones.cpp b/other/longest_subarr_ones.cpp
deleted file mode 100644
index 35f2353..0000000
--- a/other/longest_subarr_ones.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// 1493. Longest Subarray of 1's After Deleting One Element
-#include "leetcode.h"
-
-/*
- * given a binary array 'nums', you should delete one element from it. return
- * the size of the longest non-empty subarray containing only 1's in the
- * resulting array. return 0 if there is no such subarray.
- */
-
-class Solution {
-public:
- int longestSubarray(vector<int> &nums) {
- int ans = 0;
- for (int i = 0, j = 0, skip = 0; i < nums.size(); ++i) {
- skip += !nums[i];
- if (skip > 1)
- skip -= !nums[j++];
- ans = max(ans, i - j);
- }
- return ans;
- }
-};
-
-int main() {
- Solution obj;
- vector<int> n1 = {1, 1, 0, 1}, n2 = {0, 1, 1, 1, 0, 1, 1, 0, 1},
- n3 = {1, 1, 1};
- printf("%d\n", obj.longestSubarray(n1)); // expect: 3
- printf("%d\n", obj.longestSubarray(n2)); // expect: 5
- printf("%d\n", obj.longestSubarray(n3)); // expect: 2
-}