LeetCode 908 题解

https://leetcode.com/problems/super-palindromes/description/

题目大意:找数组中 最大连续的 只有两个不同数字的序列。

解题思路:暴力查找,稍微剪枝了一下,如果已经判断到了末尾就结束,水过去了。标准解法应该采用滑动窗口

class Solution {
public:
    int totalFruit(vector& tree) {
        int n = tree.size();
        int res = 0;
        int cnt =0;
        int tmp=0;
        for(int i=0;i

 

你可能感兴趣的:(leetcode)