Monday, 21 August 2023

Codeforces Round 161 Div 2 Solution in Java

Problem Statement Link --> Problem - 263A - Codeforces

Solution in JAVA:

import java.util.*;

public class test {

public static void main(String[] args) {

    int arr[][] = new int[6][6] ;

    int r=0;int c=0;

    Scanner sc = new Scanner(System.in);

    for (int i = 1; i < 6; i++) {

        for (int j = 1; j < 6; j++) {

           arr[i][j] = sc.nextInt();

           if(arr[i][j] == 1)

           {

            r = Math.abs(3-i);

            c = Math.abs(3-j);

           }

        }

    }

    System.out.println(r+c);

    sc.close();

  }   

}

No comments:

Post a Comment

Good thoughtful question on Binary search on answers

Problem link:  https://leetcode.com/problems/maximize-score-of-numbers-in-ranges/description/ Solution: //import java.util.Arrays; class So...