I wrote a code and I want to find out what is the time complexity of this program. Can anyone tell me what is the time complexity of my code?
import java.io.*;
class revenge
{
public static void main(String aargs[])throws IOException
{
BufferedReader b=new BufferedReader(
new FileReader("C://Users/Shuvro/Downloads/B-large-practice.in"));
//System.out.println("enter t");
int t=Integer.parseInt(b.readLine());
for(int i=1;i<=t;i++) {
String s1=b.readLine();
StringBuilder s=new StringBuilder(s1);
int c=0;
while(s.indexOf("-")>=0) {
for(int j=0;j<=s.lastIndexOf("-");j++) {
if(s.charAt(j)=='-')
s.setCharAt(j,'+');
else
s.setCharAt(j,'-');
}
c++;
}
System.out.println("Case #"+i+": "+c);
}
}
}
I tried to find out the complexity myself and I think its O(n^2).Am I right?