Skip to content

Commit 2e7fc30

Browse files
Question 788 has been solved.
1 parent d7cd653 commit 2e7fc30

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Q-0788 - Rotated Digits/0788.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution {
2+
public:
3+
int rotatedDigits(int n) {
4+
int count = 0;
5+
for (int i = 0; i <= n; i++) {
6+
int j = i;
7+
bool check = false;
8+
while (j > 0) {
9+
if (j % 10 == 3 || j % 10 == 4 || j % 10 == 7) {
10+
check = false;
11+
break;
12+
}
13+
else if (j % 10 == 2 || j % 10 == 5 || j % 10 == 6 || j % 10 == 9) {
14+
check = true;
15+
}
16+
j = j / 10;
17+
}
18+
if (check)
19+
count++;
20+
}
21+
return count;
22+
}
23+
};

Q-0788 - Rotated Digits/0788.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution:
2+
def rotatedDigits(self, n: int) -> int:
3+
count = 0
4+
for i in range(0,n+1):
5+
j = i
6+
check = False
7+
while (j > 0):
8+
if (j % 10 == 3 or j % 10 == 4 or j % 10 == 7):
9+
check = False
10+
break
11+
elif (j % 10 == 2 or j % 10 == 5 or j % 10 == 6 or j % 10 == 9) :
12+
check = True
13+
14+
j = int(j / 10)
15+
16+
if (check):
17+
count+=1
18+
19+
return count

0 commit comments

Comments
 (0)