-
Notifications
You must be signed in to change notification settings - Fork 30
Adding Abhishek.java File #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import java.util.*; | ||
import java.util.regex.*; | ||
import java.io.*; | ||
|
||
class pattern | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please properly format your code, indentation is not correct. |
||
public static void main(String args[]) | ||
{ | ||
|
||
Scanner sc=new Scanner(System.in); | ||
String s=sc.nextLine(); | ||
|
||
int n=sc.nextInt(); | ||
sc.nextLine(); | ||
String arr[]=new String[n]; | ||
int arr2[]=new int[100]; | ||
|
||
|
||
for(int i=0;i<n;i++) | ||
{ | ||
|
||
arr[i]=sc.nextLine(); | ||
} | ||
|
||
int k=0,count=0; | ||
for(int i=0;i<n;i++){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create a separate method to get the output. |
||
Pattern p1=Pattern.compile(arr[i]); | ||
Matcher m = p1.matcher(s); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please give some meaningful names to variables. p1, m doesn't make any sense. |
||
while(m.find()) | ||
{ | ||
arr2[k++]=m.start(); | ||
|
||
count++; | ||
} | ||
} | ||
|
||
Arrays.sort(arr2); | ||
|
||
for(int i=arr2.length-count;i<arr2.length;i++) | ||
{ | ||
System.out.print(""+arr2[i]+"\t"); | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import specific classes instead of import the whole package.