Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 045d3fc

Browse files
committed
romanToInt remove first solution
1 parent 4b1196b commit 045d3fc

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

‎README.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -200,32 +200,7 @@ Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
200200
- s contains only the characters ('I', 'V', 'X', 'L', 'C', 'D', 'M').
201201
- It is guaranteed that s is a valid roman numeral in the range [1, 3999].
202202

203-
## **Solution 1**
204-
205-
```js
206-
var romanToInt = function (s) {
207-
let result = 0;
208-
const inputArray = Array.of(...s);
209-
const romanVal = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 };
210-
const inputsVal = [];
211-
212-
inputArray.forEach((item) => {
213-
inputsVal.push(romanVal[item]);
214-
});
215-
216-
for (let i = 0; i < inputArray.length; i++) {
217-
if (inputsVal[i] < inputsVal[i + 1]) {
218-
result -= inputsVal[i];
219-
} else {
220-
result += inputsVal[i];
221-
}
222-
}
223-
224-
return result;
225-
};
226-
```
227-
228-
## **Solution 2**
203+
## **Solution**
229204

230205
```js
231206
var romanToInt = (s) => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /