C++ depth for search
\nclass Solution {\npublic:\n    string add(string s, int a) {\n        int n = s.size();\n        bool flag = true;\n        for(int i = n-1; i >= 0; i--) {\n 
```\nclass Solution {\npublic:\n    string add(string s, int a) {\n        int n = s.size();\n        bool flag = true;\n        for(int i = n-1; i >= 0; i--) {\n            if(flag) {\n                int val = a + (s[i] - \'0\');\n                val = val % 10;\n                s[i] = val + \'0\';\n                flag = false;\n            }\n            else\n                flag = true;\n        }\n        return s;\n    }\n    void dfs(string s, int a, int b, string& ans, unordered_set<string>& mark) {\n        if(mark.find(s) != mark.end())\n            return;\n        mark.insert(s);\n        ans = min(ans, s);\n        dfs(s.substr(b) + s.substr(0, b), a, b, ans, mark);\n        dfs(add(s, a), a, b, ans, mark);\n    }\n    string findLexSmallestString(string s, int a, int b) {\n         unordered_set<string> mark;\n         string ans = s;\n         dfs(s, a, b, ans, mark);\n         return ans;\n        \n    }\n};\n```
[]