Skip to content

Instantly share code, notes, and snippets.

@kuang-da
Last active October 25, 2020 20:17
Show Gist options
  • Save kuang-da/ba3297a1fb4ca795aacceedd07674e7b to your computer and use it in GitHub Desktop.
Save kuang-da/ba3297a1fb4ca795aacceedd07674e7b to your computer and use it in GitHub Desktop.
[Notes about LeetCode] #leetcode
include <stdlib.h>
include <stdio.h>
include <string>
include <string.h>
include <iostream>
include <algorithm>
include <vector>
include <unordered_map>
using namespace std;
class Solution {
public:
string findContestMatch(int n) {
vector<string> m(n);
for (int i = 0; i < n; i++) {
m[i] = to_string(i + 1);
}
while (n > 1) {
for (int i = 0; i < n / 2; i++) {
m[i] = "(" + m[i] + "," + m[n - 1 - i] + ")";
}
n /= 2;
}
return m[0];
}
};
int main(int argc, char const *argv[])
{
Solution solution;
cout << solution.findContestMatch(8);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment