File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
dsa-solutions/gfg-solutions/Basic Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ description: "This document covers methods to replace all occurrences of the dig
14
14
Given a number N. The task is to complete the function ** convertFive()** which replaces all zeros in the number with 5 and returns the number.
15
15
16
16
### Examples:
17
+
17
18
** Example 1:**
19
+
18
20
```
19
21
Input
20
22
2
@@ -49,7 +51,9 @@ Since this is a functional problem you don't have to worry about input, you just
49
51
- $1 <= N <= 10^4$
50
52
51
53
## Solution
54
+
52
55
### Python
56
+
53
57
``` python
54
58
def convertFive (self ,n ):
55
59
num_str = str (n)
@@ -63,6 +67,7 @@ def convertFive(self,n):
63
67
```
64
68
65
69
### Java
70
+
66
71
``` java
67
72
public static int convertFive(int n){
68
73
String numStr = String . valueOf(n);
@@ -71,7 +76,7 @@ public static int convertFive(int n){
71
76
char currentChar = numStr. charAt(i);
72
77
if (currentChar == ' 0' ) {
73
78
result. append(' 5' );
74
- }
79
+ }
75
80
else {
76
81
result. append(currentChar);
77
82
}
@@ -82,6 +87,7 @@ public static int convertFive(int n){
82
87
```
83
88
84
89
### C++
90
+
85
91
``` cpp
86
92
int convertFive (int n) {
87
93
string numStr = to_string(n);
@@ -96,6 +102,7 @@ int convertFive(int n) {
96
102
```
97
103
98
104
### C
105
+
99
106
```c
100
107
int convertFive(int n) {
101
108
int result = 0;
@@ -104,7 +111,7 @@ int convertFive(int n) {
104
111
int digit = n % 10;
105
112
if (digit == 0) {
106
113
result += 5 * position;
107
- }
114
+ }
108
115
else {
109
116
result += digit * position;
110
117
}
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ description: In this page, I will introduce myself.
4
4
hide_table_of_contents : true
5
5
---
6
6
7
-
8
7
import Chatbot from "../components/Chatbot";
9
8
10
9
# Introduction (परिचयः) 🙏
@@ -118,4 +117,4 @@ import Chatbot from "../components/Chatbot";
118
117
</div >
119
118
</div >
120
119
121
- <Chatbot />
120
+ <Chatbot />
You can’t perform that action at this time.
0 commit comments