Skip to content

two sum #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
roman 2 integer
  • Loading branch information
Alka107 authored Oct 27, 2021
commit cefeaaea7697cbdf72f11ba2d8469d9cdabe6b12
11 changes: 11 additions & 0 deletions 0013/roman to integer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
roman = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}

class Solution:
def romanToInt(self, s: str) -> int:
ans = 0
for i in range(len(s)-1,-1,-1):
num = roman[s[i]]
if 4 * num < ans: ans -= num
else: ans += num
return ans

12 changes: 0 additions & 12 deletions 0013/roman_to_integer.py

This file was deleted.