Guys, We can do it using single set also. It is pretty simple


#1

class Solution:
# @param A : tuple of strings
# @return an integer
def isValidSudoku(self, A):
Hash_Set=set()
for i in range(0,9):
for j in range(0,9):
value=A[i][j]
if value!=".":
if ((str(value)+ “found in row” +str(i)) in Hash_Set) or ((str(value)+ “found in column” +str(j)) in Hash_Set) or ((str(value)+ “found in Set Box” +str(i/3)+ " " +str(j/3)) in Hash_Set):
return 0

                else:
                    Hash_Set.add(str(value)+ "found in row" +str(i))
                    Hash_Set.add(str(value)+ "found in column" +str(j))
                    Hash_Set.add(str(value)+ "found in Set Box" +str(i/3)+ " " +str(j/3))
                    
                    
    return 1