There are several issues that you should be made aware of:
1. Do not #include "bits/stdc++.h" ! This is a non-standard lazy programmers' excuse for getting started in C++ that will eventually bite you! See
c++ - Why should I not #include <bits/stdc++.h>? - Stack Overflow[
^] for more info. Learn to use the STL classes and associated headers as you should.
2. I don't see any string in your code. You are using sets. As pointed out in solution 1, that will not allow you to place duplicate values in a row. At all! Also, unless you specifically say otherwise, a set will internally order all elements upon insertion, destroying the actual Sudoku row order! Even if you did understand the use of find, it wouldn't help you in getting the code to run. You
could use std::string, although that would not be my first choice - see below.
3. I've seen you have repeatedly used the insert method. This method does most certainly not what you intended, and that wouldn't be any different for any other type of container, be it set, string, or vector! 'insert' always means that you make room for a new element at the current position, and shift the rest to the right, making the container grow, and grow, and grow. Sudoku uses a fixed grid. There is no reason at all why you'd want it to grow! Therefore this cannot be correct. Note that most containers do implement the indexing operator[]. Therefore you can access individual elements for reading and writing with an index, exactly like you would do with a C array. Example:
#include <string>
#include <iostream>
int main() {
std::string my_string = "hello world";
for (size_t i = 0; i < my_string.size(); ++i)
std::cout << my_string[i];
return 0;
}
4. In your case, with a fixed grid-size that is known at compile time, the most suitable STL container would be std::array It behaves almost exactly like a C array, except, it carries the size information, saving you the effort of passing that around. See
std::array - cppreference.com[
^] for a full description and some example code.
Note that std::array does not have an insert method. And for a good reason: it can't be resized! And that's good, because you most certainly don't want to resize a Sudoku Grid on the fly!