diff --git a/Assignment-2 b/Assignment-2 new file mode 160000 index 0000000..c00ae37 --- /dev/null +++ b/Assignment-2 @@ -0,0 +1 @@ +Subproject commit c00ae37883095ffdffcdf3a3545f167419aa4f28 diff --git a/submissions/SaumyaAgrahari/question1/Screenshot (3).png b/submissions/SaumyaAgrahari/question1/Screenshot (3).png new file mode 100644 index 0000000..9591e47 Binary files /dev/null and b/submissions/SaumyaAgrahari/question1/Screenshot (3).png differ diff --git a/submissions/SaumyaAgrahari/question1/solution1 b/submissions/SaumyaAgrahari/question1/solution1 new file mode 100644 index 0000000..0052f97 --- /dev/null +++ b/submissions/SaumyaAgrahari/question1/solution1 @@ -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 + \ No newline at end of file diff --git a/submissions/SaumyaAgrahari/question2/Screenshot (4).png b/submissions/SaumyaAgrahari/question2/Screenshot (4).png new file mode 100644 index 0000000..fb8fb66 Binary files /dev/null and b/submissions/SaumyaAgrahari/question2/Screenshot (4).png differ diff --git a/submissions/SaumyaAgrahari/question2/solution2 b/submissions/SaumyaAgrahari/question2/solution2 new file mode 100644 index 0000000..2eb0f43 --- /dev/null +++ b/submissions/SaumyaAgrahari/question2/solution2 @@ -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 \ No newline at end of file