Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

developershivamshukla
Copy link

No description provided.

import java.util.regex.*;

class Shivam
{
Copy link
Contributor

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];

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;)

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
Copy link

@olleh423 olleh423 Aug 18, 2018

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());

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());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants