From 3c1cb82d37ebef36339abc1b06a8ae523b84dccb Mon Sep 17 00:00:00 2001 From: Aadarsh Mishra Date: Fri, 17 Aug 2018 21:34:30 +0530 Subject: [PATCH] Adding aadarshmishra.java file. --- aadarshmishra.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 aadarshmishra.java diff --git a/aadarshmishra.java b/aadarshmishra.java new file mode 100644 index 0000000..d5c97b0 --- /dev/null +++ b/aadarshmishra.java @@ -0,0 +1,27 @@ +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class AndroidWorkDay1 +{ + public static void main(String args[]) + { + Scanner s = new Scanner(System.in); + String text = s.nextLine(); + int n = s.nextInt(); + s.nextLine(); + List ans = new ArrayList(); + while(n-- > 0) { + String pat = s.nextLine(); + Pattern pattern = Pattern.compile(pat); + Matcher m = pattern.matcher(text); + while (m.find()) { + ans.add(m.start()); + } + } + Collections.sort(ans); + for(int i=0 ; i < ans.size() ; i++) { + System.out.print(ans.get(i) + " "); + } + } +} \ No newline at end of file