-
Notifications
You must be signed in to change notification settings - Fork 30
Adding ShivamShukla.java File #6
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?
Adding ShivamShukla.java File #6
Conversation
import java.util.regex.*; | ||
|
||
class Shivam | ||
{ |
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 do proper formatting in your code & import specific classes instead of import the whole package.
String temp=t; | ||
Scanner sc=new Scanner(System.in); | ||
int i; | ||
String a[]=new String[100]; |
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.
Avoid static allocation. if n is 5 then the rest of the memory will be wasted. if n will go more than 100 it will throw IndexOutOfBoundException.
for(i=0;i<n;i++) | ||
|
||
{ | ||
for(int j=-1;(j=temp.indexOf(a[i],j+1)) !=-1;) |
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.
Try not to use predefined methods like indexOf(). Instead you can iterate the input and match characters.
|
||
import java.util.regex.*; | ||
|
||
class Shivam |
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.
Improper indentation. Please correct
|
||
String text=sc.nextLine(); | ||
|
||
n=Integer.parseInt(sc.nextLine()); |
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.
Use sc.nextInt() instead of Integer.parseInt(sc.nextLine());
No description provided.