Amazon Coding Interview Question - Integer to Roman (LeetCode)
💰 Support me on Patreon: https://www.patreon.com/michaelmuinos
🔗Follow me on Twitter: https://twitter.com/MichaelMuinos
📂Follow me on Github: https://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.
Видео Amazon Coding Interview Question - Integer to Roman (LeetCode) канала Michael Muinos
🔗Follow me on Twitter: https://twitter.com/MichaelMuinos
📂Follow me on Github: https://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.
Видео Amazon Coding Interview Question - Integer to Roman (LeetCode) канала Michael Muinos
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Amazon Coding Interview Question - First Missing Positive (LeetCode)](https://i.ytimg.com/vi/9SnkdYXNIzM/default.jpg)
![Coding Interview Prep | 3 MUST KNOW Graph Problem Tips](https://i.ytimg.com/vi/tMSdjPKFRD4/default.jpg)
![Merge K Sorted Lists - Divide and Conquer Approach](https://i.ytimg.com/vi/BBt9FB5Yt0M/default.jpg)
![Generate Parentheses - Stack - Leetcode 22](https://i.ytimg.com/vi/s9fokUqJ76A/default.jpg)
![Convert Integer to Roman numeral - LeetCode Interview Coding Challenge [Java Brains]](https://i.ytimg.com/vi/JyLrPSJNfYw/default.jpg)
![The Top 5 Programming Languages in 2021 to get a job](https://i.ytimg.com/vi/mxKNH2gmdUc/default.jpg)
![The secrets of learning a new language | Lýdia Machová](https://i.ytimg.com/vi/o_XVt5rdpFY/default.jpg)
![AMAZON CODING INTERVIEW QUESTION - LONGEST COMMON PREFIX (LeetCode)](https://i.ytimg.com/vi/1YQmI7F9dJ0/default.jpg)
![Python Programming Practice: LeetCode #13 -- Roman to Integer](https://i.ytimg.com/vi/_5MYW7n1U-I/default.jpg)
![Container with Most Water - Leetcode 11 - Python](https://i.ytimg.com/vi/UuiTKBwPgAo/default.jpg)
![Binary Tree Maximum Path Sum (Animated Walkthrough) (LeetCode)](https://i.ytimg.com/vi/6cA_NDtpyz8/default.jpg)
![Sliding Window Algorithm - Longest Substring Without Repeating Characters (LeetCode)](https://i.ytimg.com/vi/4i6-9IzQHwo/default.jpg)
![Big O Notation Explained for Beginners](https://i.ytimg.com/vi/2Cyy9Oxerbg/default.jpg)
![Solving Amazon's 2020 Most Asked Interview Question](https://i.ytimg.com/vi/Nj2Bpw1KKds/default.jpg)
![Mock Google interview (for Software Engineer job) - coding & algorithms tips](https://i.ytimg.com/vi/IWvbPIYQPFM/default.jpg)
![Roman to Integer | LeetCode 13 | Coding Interview Tutorial](https://i.ytimg.com/vi/9rfe5nXL05Q/default.jpg)
![Boyer Moore Majority Vote Algorithm](https://i.ytimg.com/vi/gY-I8uQrCkk/default.jpg)
![AMAZON CODING INTERVIEW QUESTION - MERGE TWO SORTED LISTS (LeetCode)](https://i.ytimg.com/vi/K63Mjf-H0B0/default.jpg)
![Common Mistakes By New Software Developers](https://i.ytimg.com/vi/k73pCbdDh6I/default.jpg)
![Roman to Integer | google technical interview question | python| leetcode 13](https://i.ytimg.com/vi/MUUc4GFvlL0/default.jpg)