Build query matrix
Arrays . fill ( arr , 0 ) ; int query [ ] [ ] = { { 1 , 1 , 2 } , { 1 , 4 , 5 } , { 2 , 1 , 2 } , { 2 , 1 , 3 } , { 2 , 3 , 4 } } ; int record [ ] = new int [ m ] ; Arrays . fill ( record , 0 ) ; for ( int i = m - 1 ; i >= 0 ; i -- ) {