
Do you need help with
我当时的做法是一个hashmap, key是值,val是list of 值的 position,然后没来一个相同的值,判断他和所有的pos是不是冲突一种更简单的方法是双循环for i, j, 每次i循环用3个hashset检查第i行, 第i列和第i个方块 for(int i = 0; i<9; i++){ HashSet<Character> rows = new HashSet<Character>(); HashSet<Character> columns = new HashSet<Character>(); HashSet<Character> cube = new HashSet<Character>(); for (int j = 0; j < 9;j++){ if(board[i][j]!='.' && !rows.add(board[i][j])) return false; if(board[j][i]!='.' && !columns.add(board[j][i])) return false; int RowIndex = 3*(i/3); int ColIndex = 3*(i%3); if(board[RowIndex + j/3][ColIndex + j%3]!='.' && !cube.add(board[RowIndex + j/3][ColIndex + j%3])) return false; } }
Then try StudyFetch, the AI-powered platform that can answer your questions and teach you more about it!


How StudyFetch Helps You Master This Topic
AI-Powered Explanations
Get in-depth, personalized explanations on this topic and related concepts, tailored to your learning style.
Practice Tests
Take adaptive quizzes that focus on your weak areas and help reinforce your understanding of the subject.
Interactive Flashcards
Review key concepts and terms with AI-generated flashcards, optimizing your retention and recall.
Educational Games
Engage with fun, interactive games that reinforce your learning and make studying more enjoyable.
Start mastering this topic and many others with StudyFetch's comprehensive learning tools.