import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        String[] wallpaper_1 = {".#...", "..#..", "...#."};
        String[] wallpaper_2 = {"..........", ".....#....", "......##..", "...##.....", "....#....."};
        String[] wallpaper_3 = {".##...##.", "#..#.#..#", "#...#...#", ".#.....#.", "..#...#..", "...#.#...", "....#...."};
        String[] wallpaper_4 = {"..", "#."};

        int[] a = solution(wallpaper_1);
        int[] b = solution(wallpaper_2);
        int[] c = solution(wallpaper_3);
        int[] d = solution(wallpaper_4);
        System.out.println(a[0]+", "+a[1]+", "+a[2]+", "+a[3]+"\n============");
        System.out.println(b[0]+", "+b[1]+", "+b[2]+", "+b[3]+"\n============");
        System.out.println(c[0]+", "+c[1]+", "+c[2]+", "+c[3]+"\n============");
        System.out.println(d[0]+", "+d[1]+", "+d[2]+", "+d[3]+"\n============");
    }
    
    public static int[] solution(String[] wallpaper) {
        int rows = wallpaper.length;
        int cols = wallpaper[0].length();
        
        char[][] chWallpaper = java.util.Arrays.stream(wallpaper)
                                   .map(String::toCharArray)
                                   .toArray(char[][]::new);
        
        List<Integer> x = new ArrayList<>();
        List<Integer> y = new ArrayList<>();
        
        for (int i = 0; i < rows; i++) {          // 행(row) 탐색
            for (int j = 0; j < cols; j++) {
                if (chWallpaper[i][j] == '#') {
                    x.add(i);
                    y.add(j);
                }
            }
        }
        
        int[] answer = {Collections.min(x), Collections.min(y), Collections.max(x)+1, Collections.max(y)+1};
        
        return answer;
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: