c++ simple solution


  • 0
    A
    class Solution {
    public:
        string findContestMatch(int n) {
            return dfs(1, 1, n);
        }
        string dfs(int a, int i, int n)
        {
            if(i == n)
                return to_string(a);
            else
                return "(" + dfs(a , 2 * i, n) + "," + dfs(2 * i + 1 - a, 2 * i, n) + ")";
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.