Update appNew update is available. Click here to update.
About
I am a junior student majoring in CS. I am an aspiring software developer and Machine Learning Engineer. I am working to sharpen my skills and knowledge.
Faculty of Engineering,Lucknow University 2025
C++ - Default language
My Stats
EXP gained
yellow-spark
3458
Level
5 (Champion)
Community stats
Discussions
1
Upvotes
3
Know more
62
Total problems solved
53
Easy
8
Moderate
1
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

5 days

Less

More

Achievements
2
Ronin
Topics
Arrays
Sorting
Discussions
What's wrong with this code? All five test cases are passing but on submission only 7/11 testcases are passing.
Interview problems

int traffic(int n, int m, vector<int> vehicle) {

    int max1 =0;

    int cnt =0;

    for(int i=0;i<n;i++){

      if (vehicle[i] == 0 && m > 0) {

        vehicle[i] = 1;

        m--;

      }

    }

 

    for(int j=0;j<n;j++){

    if(vehicle[j]==1){

        cnt++;

    }

    else{

        cnt =0;

    }

    max1 = max(max1, cnt);

    }

    return max1;

}

profile
AnjuMau8418
Published On 24-Aug-2023
115 views
0 replies
0 upvotes