Amazon Coding Interview Question - Integer to Roman (LeetCode)

  Рет қаралды 20,546

AlgosWithMichael

AlgosWithMichael

Күн бұрын

Check out my interview prep platform for learning the patterns!
📢 Interview Prep Platform: algoswithmichael.com
🎧 Join the community Discord: / discord
💰 Support me on Patreon: / michaelmuinos
🔗Follow me on LinkedIn: / michael-muinos
📂Follow me on Github: github.com/MichaelMuinos
Integer to Roman is a popular LeetCode coding question asked at many tech companies including Amazon, Google, Apple, Bloomberg, and Adobe. This algorithm question is a math based question involving the use of the division and modulus operators.
To solve this problem, we first must define all roman numerals that we could potentially have in our result. Roman numerals do have some odd edge cases where occasionally we must perform subtraction from the roman numeral on the right to the roman numeral on the left. Once we have all of our conversions ranging from 1000 to 1, we then can convert any integer to a roman numeral.
We loop over all of our numerals and divide the number from our input number. The result from division is the number of symbols we must add to our result for that specific conversion. Once we append the roman numeral(s) to our result, we then utilize the modulus operator to chop off the most significant digit from our input number. We do this for each conversion until our input number becomes zero.
The time complexity of our solution is going to be big oh of N where N is the number of roman numeral characters we have in our result. We use the repeat function in Java to generate all of the characters. Our space complexity is constant since we do not initialize any extra memory in the algorithm.

Пікірлер: 48
@SarveshKumar-nh3pd
@SarveshKumar-nh3pd 3 жыл бұрын
your videos keep getting better ! thanks a lot!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Glad to hear, thanks for watching!
@vaibhavjoshi5424
@vaibhavjoshi5424 3 жыл бұрын
Upload more videos man. You explain the concepts so smoothly and simply
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
New video every week, thanks for watching!
@z41n70
@z41n70 3 жыл бұрын
Great video! Helps understand the power of creating a class
@coderart__2802
@coderart__2802 3 жыл бұрын
Superb Explanation... Loved it - after you explained how to solve it, I myself tried to code and solved the problem too... Thankyou
@MrUGOTpwNEDbyme
@MrUGOTpwNEDbyme 3 жыл бұрын
Subbed. Good to see another individual join the party of coding gurus! I'm sure your channel will grow in no time!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thank you for the kind words!
@mystica3312
@mystica3312 3 жыл бұрын
Awesome explanation!! keep them coming!!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks, will do!
@akshatpahwa534
@akshatpahwa534 2 жыл бұрын
Nice explanation!
@haacki4720
@haacki4720 Жыл бұрын
Thanks for much details!
@AlgosWithMichael
@AlgosWithMichael Жыл бұрын
No problem!
@nithyahere
@nithyahere 3 жыл бұрын
Awesome explanation!! Thanks
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Anytime!
@anmolrana96
@anmolrana96 3 жыл бұрын
Simply Amazing!!
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks a lot!
@cleo0318
@cleo0318 3 жыл бұрын
Excellent explanation and graphic to go along with it! Please make more content like this :)
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks, will do!
@pedrovalentino6684
@pedrovalentino6684 3 жыл бұрын
Awesome man. Just awesome 👏
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks a ton!
@ZhouHaibo
@ZhouHaibo 3 жыл бұрын
Good explain especially on O(n) time complexity part.
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thank you!
@roadtothecto2744
@roadtothecto2744 3 жыл бұрын
Cool explanation, thank you
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
You are welcome!
@yuklia
@yuklia 3 жыл бұрын
Thanks for the simple explanation=)
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
You're welcome!
@bitqahdi6592
@bitqahdi6592 3 жыл бұрын
Oh Man ! Great Stuff dude
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Appreciate it!
@lasredchris
@lasredchris 3 жыл бұрын
I understand having map entries for all the roman numerals in the problem statement - I, V, X, L, etc What was the thought process/reasoning you had for also having map entries for the additional ones - CM, CD, XC, etc?
@surajsingh-sm7qx
@surajsingh-sm7qx 3 жыл бұрын
nice explanation
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thanks!
@RAHULKUMAR-fn1fj
@RAHULKUMAR-fn1fj 3 жыл бұрын
you are amazing dude !!! thanks
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
no problem, thanks for watching!
@kunalgiri6114
@kunalgiri6114 3 жыл бұрын
Thanks man👍👍👍
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
anytime!
@pushkarkumar7173
@pushkarkumar7173 3 жыл бұрын
Plz upload video frequently . your videos are awesome . also make video of dynamic programming
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Thank you, I appreciate you watching!
@graceanglc
@graceanglc 3 жыл бұрын
What kind of mic do u use? It's so good I can hear your voice clearly, thanks for the leetcode videos it helps me to learn a lot
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
It is a Blue Yeti microphone, it has worked well for me so far!
@doobas2171
@doobas2171 Жыл бұрын
Finally an English first language person
@adityarathore8892
@adityarathore8892 3 жыл бұрын
subscribed :)
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
Awesome!
@ranajitmukherjee9789
@ranajitmukherjee9789 3 жыл бұрын
Why not use a hashmap? simply store the key value pairs
@AlgosWithMichael
@AlgosWithMichael 3 жыл бұрын
You can do that as well
@niteshrana5750
@niteshrana5750 7 ай бұрын
Math.floor(num/numeral.value)
Amazon Coding Interview Question - First Missing Positive (LeetCode)
20:47
Integer to Roman | Leetcode #12
17:34
Techdose
Рет қаралды 36 М.
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 4 МЛН
1❤️
00:17
Nonomen ノノメン
Рет қаралды 13 МЛН
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 24 МЛН
FAANG Coding Interview Question - Container With Most Water (LeetCode)
13:30
Integer to Roman - Leetcode 12 - Python
9:43
NeetCode
Рет қаралды 64 М.
5 Most Common Amazon Coding Interview Questions for 2022
21:52
Airbnb Coding Interview Question - Koko Eating Bananas [LeetCode]
21:27
Minimum Window Substring | Sliding Window | LeetCode
18:00
AlgosWithMichael
Рет қаралды 38 М.
Kadane's Algorithm - Maximum Subarray (Dynamic Programming)
8:24
AlgosWithMichael
Рет қаралды 24 М.
Design Tic Tac Toe: Low Level Design Coding Interview Question
15:35
Roman To Integer | Leetcode 13
10:21
Techdose
Рет қаралды 12 М.
GamePad İle Bisiklet Yönetmek #shorts
0:26
Osman Kabadayı
Рет қаралды 635 М.