力扣---2020.3.4
994. 腐烂的橘子 class Solution { int [ ] dr = new int [ ] { - 1 , 0 , 1 , 0 } ; int [ ] dc = new int [ ] { 0 , - 1 , 0 , 1 } ; public int orangesRotting ( int [ ] [ ] grid ) { int R = grid . length , C = grid [ 0 ] . length ; // queue : all starting cells with rotten oranges Queue < Integer > queue = new ArrayDeque ( ) ; Map < Integer , Integer > depth = new HashMap ( ) ; for ( int r = 0 ; r < R ; ++ r ) for ( int c = 0 ; c < C ; ++ c ) if ( grid [ r ] [ c ] == 2 ) { int code = r * C + c ; queue . add ( code ) ; depth . put ( code , 0 ) ; } int ans = 0 ; while ( ! queue . isEmpty ( ) ) { int code =