Added 14 solutions
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Solution {
|
||||
|
||||
public static void main(String[] args) {
|
||||
/* Read input */
|
||||
Scanner scan = new Scanner(System.in);
|
||||
String s = scan.nextLine();
|
||||
scan.close();
|
||||
|
||||
/* Must trim String to pass test cases. Still unclear why it's necessary */
|
||||
s = s.trim();
|
||||
|
||||
/* Check special cases */
|
||||
if (s.length() == 0) {
|
||||
System.out.println(0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Split on all non-alphabetic characters */
|
||||
String [] words = s.split("[^a-zA-Z]+");
|
||||
|
||||
/* Print output */
|
||||
System.out.println(words.length);
|
||||
for (String word : words) {
|
||||
System.out.println(word);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user