Cpp-recursion-sudoku solver

the approach sir teach in this video is use recursion and backtracking but is there any way or any approach by which we can optimise this code

Hey @sahudilip138
No sudoku can’t be solved with more optimised way as far as I know
Though a solution using Color Graphing also exist but its less efficient than backtracking.

In interviews u are expected to solve a sudoku by backtracking only.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

yes we have to use backtracking and recursion but canplace function be can optimise or not

Canplace function is already O(1) because n is 9 and its doing 36 conparisons in it
It can’t be optimised further

One optimisation can be that before calling solve function u check all the places where u have to place some number and store it in vector
Then in solve function traverse that vector instead of whole matrix