Java solution for codeforces problem 158A. The problem is "Next Round" on codeforces (a competitive coding platform).
YouTube video link : click here Question link : click here
Solution : in Java
import java.util.Scanner;
public class NextRound {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int arr[] = new int[n];
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
}
if(arr[k-1]>0){
while(k<n){
if(arr[k-1]>arr[k]){
break;
}
k++;
}
}
else{
while(k>0){
if(arr[k-1]>0){
break;
}
k--;
}
}
System.out.println(k);
}
}
Thanks for visiting
0 Comments