We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b3f28c7 commit a935f68Copy full SHA for a935f68
scripts/algorithms/C/Count Distinct Numbers on Board/Count Distinct Numbers on Board.cpp
@@ -0,0 +1,13 @@
1
+// Runtime: 4 ms (Top 11.09%) | Memory: 6.90 MB (Top 9.31%)
2
+
3
+class Solution {
4
+public:
5
+ unordered_set<int> s;
6
+ int distinctIntegers(int n) {
7
+ s.insert(n);
8
+ for(int i = 2; i < n; ++i) {
9
+ if(n%i == 1 && s.find(i) == s.end()) distinctIntegers(i);
10
+ }
11
+ return s.size();
12
13
+};
0 commit comments