File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 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+ };
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments