sample code
unknown
java
4 years ago
824 B
5
Indexable
package com.box.data.platform.server.controller.biquery.table; /** * */ public class TEST { public static void main(String[] args) { String s = "1B 2F 3C"; int N = 10; int[][] array = new int[N][10]; String[] seats = s.split(""); for (String seat: seats) { int row = seat.charAt(0); int col = seat.charAt(1); array[row][col] = 1; } System.out.println(arrangeFamily(array)); } public static int arrangeFamily(int[][] array) { int familyCount = 0; for (int i=0;i<array.length;i++) { int counter =0; for (int j=1;j<array[0].length-1;j++) { if (array[i][j] == 1) { counter =0; } //family have to sit together if (j==3 && counter == 0) { continue; } if (counter == 4) { familyCount++; } } } return familyCount; } }
Editor is loading...