You are viewing a single comment's thread. Return to all comments →
If it doesn't trim() , it will not pass all the test even if they output the same thing
Why?
I would like to know
import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.nextLine(); scan.close(); if (s.trim().length()==0 || s.trim().length()>400000){ System.out.println(0); return; } s=s.trim(); String regex = "[^(a-zA-Z)]+"; String [] lista =s.split(regex); System.out.println(lista.length); for(String k:lista){ System.out.println(k); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java String Tokens
You are viewing a single comment's thread. Return to all comments →
Why it needs to trim()?
If it doesn't trim() , it will not pass all the test even if they output the same thing
Why?
I would like to know