import java.util.;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int k = sc.nextInt();
int s = sc.nextInt();
if(n>=1 && m>=1 && k>= 1 && s>=1 && n<=100 && m<=100 && k<=100 && s<=100)
{
char[][] arr = new char[n][m];
for(int i =0 ; i<n ; i++)
{
for(int j = 0 ; j < m ; j++)
{
arr[i][j] = sc.next().charAt(0);
}
}
System.out.print(piymagic(arr,k,s));
}
}
public static int piymagic(char[][] arr ,int k , int s)
{
String str = βYesβ;
for(int i = 0 ; i<arr.length; i++)
{
for(int j =0 ; j<arr[i].length ; j++)
{
if(arr[i][j] == β.β)
{
if(s>k)
{
s = s -3;
}
else
{
str = βNoβ;
return s;
}
}
if(arr[i][j] == 'β)
{
if(s>k)
{
s = s +4;
}
else
{
str = βNoβ;
return s;
}
}
if(arr[i][j] == β#β)
{
if(s>k)
{
s = s -1;
break;
}
else
{
str = βNoβ;
return s;
}
}
}
s= s+1;
}
System.out.println(str);
return s;
}
}
Piyush and magical (my all test cases does not passes
@mayanktiwari6957 why are yor complicating the logic bro, it is straight forward question, clearly mentioned if answer is βNoβ you donβt have to print any integer just βNOβ. Read the question carefully.
Here is your simplified code