求珠子的长度最小区间-成都快上网建站

求珠子的长度最小区间

有一串首尾相连的珠子,共有m个,每一个珠子有一种颜色,并且颜色的总数不超过n(n<=10),求连续的珠子的颜色总数为n时,长度最小的区间。

#include 
using namespace std;
#define MAXN 10
int colors[MAXN];//record the counter of one color
int colorsCounter;
void find(int arr[],int len, int colorsNeed)
{
    int bestStartIndex = 0;
    int bestLen = len;
    int lastStartIndex = 0;
    
    for ( int i=0; i1) {
                colors[arr[j]]--;
                ++j;
            }
            if (i-j+1            
            
                                
网站名称:求珠子的长度最小区间
网站网址:http://kswjz.com/article/gdsgso.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流