Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Assignment-2
Submodule Assignment-2 added at c00ae3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions submissions/SaumyaAgrahari/question1/solution1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution:
def romanToInt(self, s):
roman = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000
}

total = 0

for i in range(len(s)):
# If next symbol is larger, subtract current; else, add it
if i + 1 < len(s) and roman[s[i]] < roman[s[i + 1]]:
total -= roman[s[i]]
else:
total += roman[s[i]]

return total

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions submissions/SaumyaAgrahari/question2/solution2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:
def strStr(self, haystack, needle):
len_h = len(haystack)
len_n = len(needle)
if len_n == 0:
return 0

for i in range(len_h - len_n + 1):
if haystack[i:i + len_n] == needle:
return i

return -1