Roman to Integer | google technical interview question | python| leetcode 13

preview_player
Показать описание


Please like the video, this really motivates us to make more such videos and helps us to grow. thecodingworld is a community which is formed to help fellow student and professionals looking to crack the “coding interviews”.

We love solving and sharing problems which are frequently asked in technical interviews and voted by community at various websites.

✅ For more and upcoming updates join our community

#leetcode #python
Рекомендации по теме
Комментарии
Автор

Really good explanation.. your voice is good. While listening the music I feel like I am watching some cooking video. It is a suggestion. Please Don’t mind

dimmyt
Автор

Thanks..very Nice helpful ...great work...I understand it now..:)

Автор

Music is Tool Loud please next Timer just your Voice or Turn down music Volumen thanks BTW Great Video easy tonunderstand

makarov_artz
Автор

just one
please remove song from background 😅😅😅😅
it distracts us from understanding,
otherwise great explanation👍👍👍

VishalKumar-pkek
Автор

I liked your explanation the best because you dry run as well as show the real code in python.

pranayrajwade
Автор

Your way of teaching concepts is really great, except for the music running in the background, especially while playing the video is 1.5x speed. Better if you remove the music. Yeah, btw, great explanation.

mithileshgautam
Автор

great video and love the explanations but background music is too lound and distracting

VikasKM
Автор

Thanks. I borrowed your idea and enhance solution as follows -
class Solution:
def romanToInt(self, s: str) -> int:
result = 0

prev = 0

symbols = {'I':1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}

for i in range(len(s)):
cur = symbols[s[i]]

result += cur

if cur > prev:
result -= 2 * prev

prev = cur


return result

ogsconnect
Автор

This is so far the best explanation on YouTube .

anshulvairagade
Автор

In starting (line 18) we don't need assignment of curr=0. Without that also it works.

deepaleekhare
Автор

bro your previous video is better without sound effect .

arthgupta
Автор

Great explanation.Keep up the good work. Thanks.

annjames
Автор

this is a good video man, keep it up!

tanmaysharma
Автор

I like the explanation and solution! thank you! I solved this in a different way. I reversed the string and then iterated that way. If current number I was on was less than the previous number then i just subtracted the current number. check it out !

def convertToInt(romanNumber) -> int:
romanDict = {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000}
sum = prev = 0

for num in romanNumber[::-1]:
if romanDict[num] < prev:
sum -= romanDict[num]
else:
sum += romanDict[num]
prev = romanDict[num]
return sum

I tried this with these numbers and it seemed to work "MCDXCIV" = 1494, "XLIV" = 44, "MMMMCLXXXIV" = 4184

I love your videos. They are very helpful for preparing for interviews and technical problem solving!

mac__
Автор

What if the given input is 55. We dint give any condition if prev == current

meghanareddi
Автор

Thanks for this video..Helped a lot :)

AyushiSharmaDSA
Автор

can u make videos on problem no 4 and 10 of leetcode?

techdiscussion
Автор

sir why did you -2(previous ) when IV is occur we can simply subtract the of smaller one ?

khushbookumari
Автор

Thank you very much, nicely exlplined

colabpython
Автор

What's the time and space complexity of this solution?

sourishisavailable
welcome to shbcf.ru