Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 393 Bytes

File metadata and controls

24 lines (19 loc) · 393 Bytes

String TLE

String Concatenations using one character at a time

  • The below code will take O(n^2) time
String s = "" 
for(int i=0;i<n;i++) 
{ 
        s += "1"; 
} 
  • The below code will take O(n) time.
char arr[] = new char[n]; 
for(int i=0;i<n;i++){ 
        arr[i] = '1'; 
} 
String str = String.valueOf(arr) ;