- Joined
- 1/21/19
- Messages
- 313
- Points
- 138
Hi ,
I want to implement the JAVA solution to the valid sudoku problem on LeetCode in C++. It uses hashset<hashset> form . I understand std::unordered_set<std::unordered_set<int>> would be the ideal DS but I am struggling to default initialize it . You can see the snippet of the JAVA solution below ,
Any help would be much appreciated !
Thanks
I want to implement the JAVA solution to the valid sudoku problem on LeetCode in C++. It uses hashset<hashset> form . I understand std::unordered_set<std::unordered_set<int>> would be the ideal DS but I am struggling to default initialize it . You can see the snippet of the JAVA solution below ,
Java:
public boolean isValidSudoku(char[][] board) {
int N = 9;
// Use hash set to record the status
HashSet<Character>[] rows = new HashSet[N];
HashSet<Character>[] cols = new HashSet[N];
HashSet<Character>[] boxes = new HashSet[N];
for (int r = 0; r < N; r++) {
rows[r] = new HashSet<Character>();
cols[r] = new HashSet<Character>();
boxes[r] = new HashSet<Character>();
}
.....
}
Any help would be much appreciated !
Thanks