作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 虫取法/双指针 日期 题目地址:https://leetcode.com/problems/max-consecutive-ones-iii/ 题目描述 Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of the l…
题目如下: Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of the longest (contiguous) subarray that contains only 1s. Example 1: Input: A = [1,1,1,0,0,0,1,1,1,1,0], K = 2 Output: 6 Explanation: [1,1,1,0,0,1,1,1,…
problem 485. Max Consecutive Ones solution1: class Solution { public: int findMaxConsecutiveOnes(vector<int>& nums) { ; , max = INT_MIN; ; i<nums.size(); i++) { ) ans++; ) { if(max<ans) max = ans; ans = ; } } return max>ans ? max : ans;…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 [LeetCode] 题目地址:https://leetcode.com/problems/max-consecutive-ones/ Difficulty: Easy 题目描述 Given a binary array, find the maximum number of consecutive 1s in…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 日期 题目地址:https://leetcode-cn.com/problems/max-consecutive-ones-ii/ 题目描述 Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most…
[LeetCode]556. Next Greater Element III 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/next-greater-element-iii/description/ 题目描述: Given a positive 32-bit integer n, you need…
原题链接在这里:https://leetcode.com/problems/max-consecutive-ones-iii/ 题目: Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of the longest (contiguous) subarray that contains only 1s. Example 1: Input: A = [1,1,1,0,…
Single Number I : Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Solution: 解法不少,贴一种: class…
Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典+最大公约数 日期 题目地址:https://leetcode.com/problems/max-points-on-a-line/description/ 题目描述 Given n points on a 2D plane, find the maximum number of points that lie on the same strai…