Ive passed a test yesterday and I did not do great on it.
(我昨天通过了考试,但我做得不好。)
The thing is it a 2d grid, inputs are column number(int), row number(int) and the grid(List>).
(事情是它是2d网格,输入是列号(int),行号(int)和网格(List>)。)
each case can eaither be in a 0 or a 1 state. (每种情况都可以处于0或1状态。)
The goal is to find the number of adjuscent rows that are in a 0 state (including the case itself) This is my try but its not working: (目标是找到处于0状态(包括大小写本身)的辅助行数。这是我的尝试,但不起作用:)
int minimumHours(int rows, int columns, List<List<Integer> > grid)
{
int cpt=0;
List<Integer> keepc = Arrays.asList(columns-2,columns-1,columns);
List<Integer> keepr = Arrays.asList(rows-2,rows-1,rows);
for (List<Integer> row : grid.stream()
.filter(i -> keepr.contains(i))
.collect(Collectors.toList()) ) {
for(int column:row.stream()
.filter(j -> keepc.contains(j))
.collect(Collectors.toList())) {
cpt=column==0?cpt+1:cpt;
}
}
return cpt;
}
ask by pochi translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…