sholay part 2.please share better solutions.my solution is giving time out
Page 1 of 1
sholay part 2.please share better solutions.my solution is giving time out
package program;
import java.util.Scanner;
public class fuzzy {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int l1=sc.nextInt();
int l2=sc.nextInt();
String a[]=new String[l1];
String b[]=new String[l2];
for(int i=0;i<l1;i++)
{
a[i]=sc.next();
}
for(int i=0;i<l2;i++)
{
b[i]=sc.next();
}
int c=0;
for(int i=0;i<l1;i++)
{
for(int j=0;j<l2;j++)
{
int f=0;
String app=a[i].concat(b[j]);
for(int k=65;k<=90;k++)
{
if(app.indexOf((char)k)==-1)
{
f=1;
break;
}
}
if(f==0)
{
c++;
}
}
}
System.out.println(c);
}
}
import java.util.Scanner;
public class fuzzy {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int l1=sc.nextInt();
int l2=sc.nextInt();
String a[]=new String[l1];
String b[]=new String[l2];
for(int i=0;i<l1;i++)
{
a[i]=sc.next();
}
for(int i=0;i<l2;i++)
{
b[i]=sc.next();
}
int c=0;
for(int i=0;i<l1;i++)
{
for(int j=0;j<l2;j++)
{
int f=0;
String app=a[i].concat(b[j]);
for(int k=65;k<=90;k++)
{
if(app.indexOf((char)k)==-1)
{
f=1;
break;
}
}
if(f==0)
{
c++;
}
}
}
System.out.println(c);
}
}
akarshsomani- Posts : 21
Join date : 2017-04-04
Similar topics
» class and objects assignment solutions.
» constructor and destructor assignment solutions
» SMARKET SOLUTION
» ROWSOLD SOLUTION
» DISH OF LIFE SOLUTION
» constructor and destructor assignment solutions
» SMARKET SOLUTION
» ROWSOLD SOLUTION
» DISH OF LIFE SOLUTION
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum