"Leetcode 36_ Hash Table" Valid Sudoku

Source: Internet
Author: User

1 //occupyed_1 Check whether rows occupy2 //occupyed_2 Check whether the column occupies3 //Occupyed_3 Check if the block is occupied4 BOOLIsvalidsudoku (vector<vector<Char>>&Board)5 {6     intoccupyed_1[9][9], occupyed_2[9][9], occupyed_3[9][9];7      for(inti =0; I <9; ++i) {8          for(intj =0; J <9; ++j) {9OCCUPYED_1[I][J] =0;TenOCCUPYED_2[I][J] =0; OneOCCUPYED_3[I][J] =0; A         } -     } -  the     intRowsize =board.size (); -     intColsize = board[0].size (); -      for(inti =0; i < rowsize; ++i) { -          for(intj =0; J < Colsize; ++j) { +             if(Board[i][j]! ='.') { -                 intnum = board[i][j]-'0'-1; +                 intK = I/3*3+ J/3; A  at                 if(Occupyed_1[i][num] | |Occupyed_2[j][num] -||Occupyed_3[k][num]) -                     return false; -Occupyed_1[i][num] =1; -Occupyed_2[j][num] =1; -Occupyed_3[k][num] =1; in             } -         } to     } +     return true; -}

"Leetcode 36_ Hash Table" Valid Sudoku

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.