Solution 2 for Scaler Topics Fortnightly Contest - 2
Learn via video course

DSA Problem Solving for Interviews using Java
by Jitender Punia
1000
4.9
This article is part of the Scaler Topics Fortnightly Contest - 2.
Solution Approach
- Brute Force: Backtracking
- Optimised: ans = 4 * A * A-1. Notice that the problem is asking about number of hamiltonian path in a N-wheel graph.