⭐️  [ Kt, Js, Py3, Cpp ] 🌪  Brute-Force via 🚀  DFS + 🚌  BFS
Synopsis:\n\nBrute-force check all possibilities via the following two mutations:\n\nCase 1: let a be the amount we will increment each odd indexed character c 
**Synopsis:**\n\nBrute-force check all possibilities via the following two mutations:\n\n**Case 1:** let `a` be the `amount` we will `increment` each odd indexed character `c` of the input string `s`\n**Case 2:** let `b` be the `pivot` index at which we `rotate` the input string `s`\n\nReturn the lexicographical minimum string as the `best` answer.\n\n---\n\n**`\uD83D\uDE80` DFS Solutions:**\n\n*Kotlin*\n```\nclass Solution {\n    fun findLexSmallestString(s: String, amount: Int, pivot: Int): String {\n        var ord: (Char) -> Int = { c: Char -> c.toInt() }\n        var best = s\n        var seen = mutableSetOf<String>()\n        fun go(s: String): Unit {\n            if (best > s)\n                best = s\n            var increment = s.mapIndexed{ i, c -> if (i % 2 == 1) (ord(\'0\') + (ord(c) - ord(\'0\') + amount) % 10).toChar() else c }.joinToString("")\n            if (!seen.contains(increment)) {\n                seen.add(increment); go(increment)\n            }\n            var rotate = s.substring(pivot) + s.substring(0, pivot)\n            if (!seen.contains(rotate)) {\n                seen.add(rotate); go(rotate)\n            }\n        }\n        go(s)\n        return best\n    }\n}\n```\n\n*Javascript*\n```\nlet findLexSmallestString = (s, amount, pivot, best = s, seen = new Set([ s ])) => {\n    let ord = c => c.charCodeAt(0);\n    let go = s => {\n        if (0 < best.localeCompare(s))\n            best = s;\n        let increment = s.split(\'\').map((c, i) => i & 1 ? String.fromCharCode(ord(\'0\') + (ord(c) - ord(\'0\') + amount) % 10) : c).join(\'\');\n        if (!seen.has(increment))\n            seen.add(increment), go(increment);\n        let rotate = s.substring(pivot) + s.substring(0, pivot);\n        if (!seen.has(rotate))\n            seen.add(rotate), go(rotate);\n    };\n    go(s);\n    return best;\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def findLexSmallestString(self, s: str, amount: int, pivot: int) -> str:\n        best = s\n        seen = set([ s ])\n        def go(s):\n            nonlocal best\n            if best > s:\n                best = s\n            increment = \'\'.join([str((int(c) + amount) % 10) if i & 1 else c for i, c in enumerate(s)])\n            if increment not in seen:\n                seen.add(increment); go(increment)\n            rotate = s[pivot:] + s[:pivot]\n            if rotate not in seen:\n                seen.add(rotate); go(rotate)\n        go(s)\n        return best\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using Set = unordered_set<string>;\n    using fun = function<void(string)>;\n    string findLexSmallestString(string s, int amount, int pivot) {\n        auto best{ s };\n        Set seen{ s };\n        fun go = [&](auto s) {\n            if (best > s)\n                best = s;\n            string increment;\n            transform(s.begin(), s.end(), back_inserter(increment), [i = -1, amount](auto c) mutable {\n                return ++i & 1 ? (((c - \'0\') + amount) % 10) + \'0\' : c;\n            });\n            if (seen.insert(increment).second)\n                go(increment);\n            auto rotate = s.substr(pivot) + s.substr(0, pivot);\n            if (seen.insert(rotate).second)\n                go(rotate);\n        };\n        go(s);\n        return best;\n    }\n};\n```\n\n---\n\n**`\uD83D\uDE8C` BFS Solutions:**\n\n*Kotlin*\n```\nclass Solution {\n    fun findLexSmallestString(s: String, amount: Int, pivot: Int): String {\n        var ord: (Char) -> Int = { c: Char -> c.toInt() }\n        var best = s\n        var seen = mutableSetOf<String>()\n        var q: Queue<String> = LinkedList<String>(mutableListOf(s))\n        while (q.peek() != null) {\n            var cur = q.poll()\n            if (best > cur)\n                best = cur\n            var increment = cur.mapIndexed{ i, c -> if (i % 2 == 1) (ord(\'0\') + (ord(c) - ord(\'0\') + amount) % 10).toChar() else c }.joinToString("")\n            if (!seen.contains(increment)) {\n                seen.add(increment); q.add(increment)\n            }\n            var rotate = cur.substring(pivot) + cur.substring(0, pivot)\n            if (!seen.contains(rotate)) {\n                seen.add(rotate); q.add(rotate)\n            }\n        }\n        return best\n    }\n}\n```\n\n*Javascript*\n```\nlet findLexSmallestString = (s, amount, pivot, best = s, seen = new Set([ s ])) => {\n    let ord = c => c.charCodeAt(0);\n    let q = [ s ];\n    while (q.length) {\n        let cur = q.pop();\n        if (0 < best.localeCompare(cur))\n            best = cur;\n        let increment = cur.split(\'\').map((c, i) => i & 1 ? String.fromCharCode(ord(\'0\') + (ord(c) - ord(\'0\') + amount) % 10) : c).join(\'\');\n        if (!seen.has(increment))\n            seen.add(increment), q.push(increment);\n        let rotate = cur.substring(pivot) + cur.substring(0, pivot);\n        if (!seen.has(rotate))\n            seen.add(rotate), q.push(rotate);\n    }\n    return best;\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def findLexSmallestString(self, s: str, amount: int, pivot: int) -> str:\n        best = s\n        seen = set([ s ])\n        q = deque([ s ])\n        while q:\n            cur = q.popleft()\n            if best > cur:\n                best = cur\n            increment = \'\'.join([str((int(c) + amount) % 10) if i & 1 else c for i, c in enumerate(cur)])\n            if increment not in seen:\n                seen.add(increment); q.append(increment)\n            rotate = cur[pivot:] + cur[:pivot]\n            if rotate not in seen:\n                seen.add(rotate); q.append(rotate)\n        return best\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using Queue = queue<string>;\n    using Set = unordered_set<string>;\n    using fun = function<void(string)>;\n    string findLexSmallestString(string s, int amount, int pivot) {\n        auto best{ s };\n        Queue q{{{ s }}};\n        Set seen{ s };\n        while (q.size()) {\n            auto cur = q.front(); q.pop();\n            if (best > cur)\n                best = cur;\n            string increment;\n            transform(cur.begin(), cur.end(), back_inserter(increment), [i = -1, amount](auto c) mutable {\n                return ++i & 1 ? (((c - \'0\') + amount) % 10) + \'0\' : c;\n            });\n            if (seen.insert(increment).second)\n                q.push(increment);\n            auto rotate = cur.substr(pivot) + cur.substr(0, pivot);\n            if (seen.insert(rotate).second)\n                q.push(rotate);\n        }\n        return best;\n    }\n};\n```
[]