Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by Aid ( 17 years ago )
class MaxProb
{
  public static void main(String[] args)
  {
    String str=" aaa   aaa  a";
    System.out.println(getProb(str));
    System.out.println(str.indexOf("bb"));
  }
  
  public static int getProb(String str)
  {
    int res=0;
    
    if(-1 != str.indexOf(" "))
    {
      String t=" ";
      for(int i=2; i<str.length(); i++)
      {
        t=t+" ";
        if(-1 == str.indexOf(t))
        {
          res=i-1;
          break;
        }
      }
    }
    return(res);
  }
}

 

Revise this Paste

Your Name: Code Language: