Integer to Roman | Leetcode #12

preview_player
Показать описание
This video explains a critical programming interview problem: converting an integer number to a roman number. We will understand the approach in 2 essential steps. The first step is to derive the required roman notations from the given notations. The second step is to know how to break a number in the most feasible way required by the problem. This problem is among the most frequent programming interview problems and has been frequently asked for Amazon interview.
CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

======================================PLEASE DONATE=============================
==============================================================================

=======================================================================
USEFUL LINKS:

RELATED LINKS:

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

Ur explanation is in such a way that we are getting the logic in middle of the video itself

Santoshkumar-bboq
Автор

Thank you very much! For an awesome explanation. Just a quick note on the character mapping 90 should be equal to "XC".When you switch to the code this error is corrected, but I paused the video on your breakdown to write the code myself. Thanks so much for an awesome video

Lucho
Автор

Many Thanks for very detailed explanation from scratch. It helped me a lot.

abhijitbiradar
Автор

Amazing thanks for such a great explaination

himanshusingla
Автор

Great explanation, easy to understand, thank you

krishnai
Автор

ok i understood but why we need to calculate 4, 9, 40, etc ?

oyesaurabh
Автор

Instead of for loop use while loop
int i=0;
while(num>0){
if(num >= value[i]){
ans+=notation[i];
num -= value[i];
}
else{
i++;
}
}

psyknyt
Автор

91 is printing LCI since 90 is LC and remaining 1 is I which is wrong as per substraction mechanism it should be XCI

akshaygoyal
Автор

For the division approach how do I add notations[pos] x times in roman string without for loop is there any other method.

Curiousss_Shivammm
Автор

Thank you for sharing coding videos. Can you please make videos on Low Level Design as well. :) Thanks again!

RaunakShrivastava
Автор

How can we print the notation 'V' like 2 times or 3times or num/value[i] times.

ShubhamKumar-kmpm
Автор

why didn't you take 10, 000 next to 100, 000 and directly went to 1000

hiq
Автор

At 3:30 The lowest 10th multiple of 5 is 50. This means that 50 is the 10th number in the sequence of multiples of 5.

Sorry i did not get that. could you please explain it.

aditgulia
Автор

Division method

class Solution {
private static final int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
private static final String[] symbols = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};

public String intToRoman(int num) {
StringBuilder sb = new StringBuilder();
// Loop through each symbol, stopping if num becomes 0.
for (int i = 0; i < values.length && num > 0; i++) {
// Repeat while the current symbol still fits into num.
while (values[i] <= num) {
int repeat = num / values[i];
num = num % values[i];
while(repeat > 0){
sb.append(symbols[i]);
repeat --;
}
}
}
return sb.toString();
}

}

arnavkarforma
Автор

Which app do you use to create the video?

DeepakSingh-xbfq
Автор

What is name of this white board software plz?

BRAJESHKUMAR-lzmw
Автор

And this question is from easy section 😂

gauravbankar
Автор

I think you forget to add 6 to your cpp code. Maybe I'm wrong. I can't find it. 17:04

JohnSmith-gex
Автор

THE GOSPEL

Moreover, brethren, I declare unto you the gospel which I preached unto you, which also
ye have received, and wherein ye stand; 2 By which also ye are saved, if ye keep in memory what I preached unto you, unless ye have believed in vain. 3 For I delivered unto you first of all that which I also received, how that Christ died for our sins according to the scriptures; 4 And that he was buried, and that he rose again the third day according to the scriptures:
- 1 Corinthians 15: 1-4 KJV

Greater love hath no man than this, that a man lay down his life for his friends. - John 15:13 KJV

SAVALATION

For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.
- John 3:16 KJV

For God sent not his Son into the world to condemn the world; but that the world through him might be saved. John 3:17

Jesus saith unto him, I am the way, the truth, and the life: no man cometh unto the Father, but by me.
- John 14:6 KJV

Neither is there salvation in any other: for there is none other name under heaven given among men, whereby we must be saved. Acts 4:12

For if, when we were enemies, we were reconciled to God by the death of his Son, much more, being reconciled, we shall be saved by his life. Romans 5:10

But he was wounded for our transgressions, he was bruised for our iniquities: the chastisement of our peace was upon him; and with his stripes we are healed. - Isaiah 53:5

For by grace are ye saved through faith; and that not of yourselves: it is the gift of God: Not of works, lest any man should boast. Ephesians 2:8-9

And saying, The time is fulfilled, and the kingdom of God is at hand: repent ye, and believe the gospel.
- Mark 1:15 KJV


He that believeth on the Son hath everlasting life: and he that believeth not the Son shall not see life; but the wrath of God abideth on him.
- John 3:36 KJV

Who hath saved us, and called us with an holy calling, not according to our works, but according to his own purpose and grace, which was given us in Christ Jesus before the world began. 2 Timothy 1:9

For the Son of man is come to seek and to save that which was lost. Luke 19:10

The Lord is not slack concerning his promise, as some men count slackness; but is longsuffering to us-ward, not willing that any should perish, but that all should come to repentance. 2 Peter 3:9

He that believeth and is baptized shall be saved; but he that believeth not shall be damned. Mark 16:16

For as in Adam all die, even so in Christ shall all be made alive. 1 Corinthians 15:22

For scarcely for a righteous man will one die: yet peradventure for a good man some would even dare to die. But God commendeth his love toward us, in that, while we were yet sinners, Christ died for us. Romans 5:7-8

I am the door: by me if any man enter in, he shall be saved, and shall go in and out, and find pasture. John 10:9

That if thou shalt confess with thy mouth the Lord Jesus, and shalt believe in thine heart that God hath raised him from the dead, thou shalt be saved. 10 For with the heart man believeth unto righteousness; and with the mouth confession is made unto salvation. 11 For the scripture saith, Whosoever believeth on him shall not be ashamed.
- Romans 10:9-11 KJV

For whosoever shall call upon the name of the Lord shall be saved.
- Romans 10:13 KJV

For I am not ashamed of the gospel of Christ: for it is the power of God unto salvation to every one that believeth; to the Jew first, and also to the Greek. Romans 1:16

jesuschristsaves