-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwinOrlose.java
More file actions
68 lines (64 loc) · 895 Bytes
/
Copy pathwinOrlose.java
File metadata and controls
68 lines (64 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package Prep;
public class winOrlose {
public static String winorlose(int[] str,int[] ene,int n)
{
int min1=str[0],y=0,x,c,k=0;
int[] s=new int[n];
for(int i=0;i<n;i++)
{
if(str[i]<min1)
{
min1=str[i];
}
}
for(int i=0;i<n;i++)
{
int min=min1;
for(int j=0;j<n;j++)
{
if(str[j]<ene[i] && min<=str[j])
{
min=str[j];
y=j;
}
}
str[y]=0;
s[k]=y;
k++;
}
for(int j=0;j<n;j++)
{
c=0;
for(int i=0;i<n;i++)
{
if(j==s[i])
c++;
}
if(c>1)
{
return "LOSE";
}
}
return "WIN";
}
public static void main(String args[] ) throws Exception {
// Scanner sc=new Scanner(System.in);
// int t=sc.nextInt();
// while(t>0)
// {
// int n=sc.nextInt();
// int[] str=new int[n];
// int[] ene=new int[n];
// for(int i=0;i<n;i++)
// {
// str[i]=sc.nextInt();
// }
// for(int i=0;i<n;i++)
// {
// ene[i]=sc.nextInt();
// }
// System.out.println(winorlose(str,ene,n));
// t=t-1;
// }
}
}