File tree Expand file tree Collapse file tree 5 files changed +94
-0
lines changed
solution/1300-1399/1323.Maximum 69 Number Expand file tree Collapse file tree 5 files changed +94
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,42 @@ func maximum69Number(num int) int {
110
110
}
111
111
```
112
112
113
+ ### ** TypeScript**
114
+
115
+ ``` ts
116
+ function maximum69Number(num : number ): number {
117
+ return Number ((num + ' ' ).replace (' 6' , ' 9' ));
118
+ }
119
+ ```
120
+
121
+ ### ** Rust**
122
+
123
+ ``` rust
124
+ impl Solution {
125
+ pub fn maximum69_number (num : i32 ) -> i32 {
126
+ num . to_string (). replacen ('6' , " 9" , 1 ). parse (). unwrap ()
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### ** C**
132
+
133
+ ``` c
134
+ int maximum69Number (int num) {
135
+ int n = 0;
136
+ int i = 0;
137
+ int t = num;
138
+ while (t) {
139
+ n++;
140
+ if (t % 10 == 6) {
141
+ i = n;
142
+ }
143
+ t /= 10;
144
+ }
145
+ return num + 3 * pow(10, i - 1);
146
+ }
147
+ ```
148
+
113
149
### **...**
114
150
115
151
```
Original file line number Diff line number Diff line change @@ -103,6 +103,43 @@ func maximum69Number(num int) int {
103
103
}
104
104
```
105
105
106
+
107
+ ### ** TypeScript**
108
+
109
+ ``` ts
110
+ function maximum69Number(num : number ): number {
111
+ return Number ((num + ' ' ).replace (' 6' , ' 9' ));
112
+ }
113
+ ```
114
+
115
+ ### ** Rust**
116
+
117
+ ``` rust
118
+ impl Solution {
119
+ pub fn maximum69_number (num : i32 ) -> i32 {
120
+ num . to_string (). replacen ('6' , " 9" , 1 ). parse (). unwrap ()
121
+ }
122
+ }
123
+ ```
124
+
125
+ ### ** C**
126
+
127
+ ``` c
128
+ int maximum69Number (int num) {
129
+ int n = 0;
130
+ int i = 0;
131
+ int t = num;
132
+ while (t) {
133
+ n++;
134
+ if (t % 10 == 6) {
135
+ i = n;
136
+ }
137
+ t /= 10;
138
+ }
139
+ return num + 3 * pow(10, i - 1);
140
+ }
141
+ ```
142
+
106
143
### **...**
107
144
108
145
```
Original file line number Diff line number Diff line change
1
+ int maximum69Number (int num ) {
2
+ int n = 0 ;
3
+ int i = 0 ;
4
+ int t = num ;
5
+ while (t ) {
6
+ n ++ ;
7
+ if (t % 10 == 6 ) {
8
+ i = n ;
9
+ }
10
+ t /= 10 ;
11
+ }
12
+ return num + 3 * pow (10 , i - 1 );
13
+ }
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ pub fn maximum69_number ( num : i32 ) -> i32 {
3
+ num. to_string ( ) . replacen ( '6' , "9" , 1 ) . parse ( ) . unwrap ( )
4
+ }
5
+ }
Original file line number Diff line number Diff line change
1
+ function maximum69Number ( num : number ) : number {
2
+ return Number ( ( num + '' ) . replace ( '6' , '9' ) ) ;
3
+ }
You can’t perform that action at this time.
0 commit comments