How to implement check if Sudoku is valid in Java?
<p>I'd would like to implement a check to see if a sudoku is valid in Java, and came across (<a href="http://leetcode.tgic.me/valid-sudoku/index.html" rel="nofollow noreferrer">http://leetcode.tgic.me/valid-sudoku/index.html</a>). </p>

<p>I understand how it is validating rows and columns, but for the 3x3 grids validator:</p>

<pre><code>34         for(x = 0; x &lt; mx; x += 3){
35             for(y = 0; y &lt; my; y += 3){
36                 
37                 HashSet&lt;Character&gt; block = new HashSet&lt;Character&gt;();
38                 
39                 for(int offset = 0; offset &lt; 9; offset++){
40                     int ox = offset % 3;
41                     int oy = offset / 3;
42                     
43                     char c = board[x + ox][y + oy];
44                     if(c != '.'){
45                         if(block.contains(c)) return false;
46                     
47                         block.add(c);
48                     } 
49                 }
50             }
51         }
</code></pre>

<p>What is <code>offset</code> and how does it help to check every cell in the 3x3 grid? I brute forced it and tried <code>x=0, y=0</code>, <code>offset=0</code> and <code>offset=1</code> first, but <code>offset=1</code> gives <code>int ox = 1%3 = 1;</code> and <code>int oy = 1/3</code>, so the <code>board[0 + 1][0+(1/3)] = board[1][1/3]</code>, and what does cell <code>[1/3]</code> represent and so on? </p>