Skip to content

Commit 85c5199

Browse files
committed
Update roman-to-integer.cpp
add one extra condition even the leetcode didn't care about it
1 parent a57df3f commit 85c5199

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/roman-to-integer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Solution {
88
{'L', 50}, {'C', 100}, {'D', 500},
99
{'M', 1000}};
1010
return accumulate(s.crbegin() , s.crend() , 0 , [&numeral_map](int sum , char c){
11-
return sum += ((numeral_map[c] * 5 <= sum) ? -numeral_map[c]: numeral_map[c]);
11+
return sum += ((numeral_map[c] * 5 <= sum) && (c!= 'M') ? -numeral_map[c]: numeral_map[c]);
1212
});
1313
}
1414
};

0 commit comments

Comments
 (0)