File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
src/main/java/com/fishercoder/common/classes Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fishercoder .common .classes ;
2
+
3
+ import java .util .List ;
4
+
5
+ public interface BinaryMatrix {
6
+ int get (int x , int y );
7
+
8
+ List <Integer > dimensions ();
9
+ }
Original file line number Diff line number Diff line change
1
+ package com .fishercoder .common .classes ;
2
+
3
+ import java .util .ArrayList ;
4
+ import java .util .List ;
5
+
6
+ public class BinaryMatrixImpl implements BinaryMatrix {
7
+
8
+ private final int [][] matrix ;
9
+
10
+ public BinaryMatrixImpl (int [][] matrix ) {
11
+ this .matrix = matrix ;
12
+ }
13
+
14
+ @ Override
15
+ public int get (int x , int y ) {
16
+ return matrix [x ][y ];
17
+ }
18
+
19
+ @ Override
20
+ public List <Integer > dimensions () {
21
+ List <Integer > dimensions = new ArrayList <>();
22
+ dimensions .add (matrix .length );
23
+ dimensions .add (matrix [0 ].length );
24
+ return dimensions ;
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments