Practice for Microsoft 2015 Online Test register

Ended

Participants:1406

Verdict:Accepted
Score:100 / 100
Submitted:2014-10-18 13:42:22

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//10(end-start-1)
//21
//32
#include<iostream>
#include<vector>
using namespace std;
const int MAX_NUM = 100;
inline int diff(int start, int end){
    return end - start -1;
}
int max_strike(vector<int> arr, size_t card_num){
    if(card_num > arr.size()) return MAX_NUM;//
    int start = 0, end = 0, max_len = 0;
    size_t index = 0;
    
    while(index < arr.size()){
        if(index >= arr.size() - card_num) end = MAX_NUM;
        else end = arr[index+card_num];
        
        int tmp = diff(start, end);
        max_len = max_len > tmp ? max_len : tmp;
    
        start = arr[index++];
    }
    return max_len;
}
int main(){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX