#include <iostream>
#include <vector>
#include <string>

using namespace std;

int Largeststring(string nums){
  int result = 0;
  int current = 0;
  int startAt = -1;
        
  for (int i = 0; i < nums.size(); ++i) {
    if (nums[i] == '1') /* note that i-th item is a char, not (sub-)string */
      current += 1;
    else {          
      current = i - startAt;
      startAt = i;
    }
            
    result = max(current, result);
  }
        
  return result;
}

int main()
{
    string s = "1101100111";
    cout<<Largeststring(s);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: