Integer to Roman | Leetcode #12

  Рет қаралды 41,246

Techdose

Techdose

Күн бұрын

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=============================
🧡 SUPPORT OUR WORK: / techdose
💚 UPI-ID: surya.kahar@ybl
💞JOIN Membership: / @techdose4u
==============================================================================
INSTAGRAM : / surya.pratap.k
LinkedIn: / surya-pratap-kahar-47b...
WEBSITE: techdose.co.in/
TELEGRAM Channel LINK: t.me/codewithT...
TELEGRAM Group LINK: t.me/joinchat/...
=======================================================================
USEFUL LINKS:
🟠Must do TIPS to ACE Virtual Interview: • 🔴Must do Tips to ACE y...
🟢Best strategy to excel your coding interview: • 🔴Best strategy to exce...
🟡Get your dream job in 1 month: • 🔴Get your dream job in...
🔵How to crack dream job in just 2 months: • How to crack dream job...
🟣7 Days DSA plan: techdose.co.in...
RELATED LINKS:
CODE LINK: gist.github.co...

Пікірлер: 42
@Santoshkumar-bb2oq
@Santoshkumar-bb2oq Жыл бұрын
Ur explanation is in such a way that we are getting the logic in middle of the video itself
@Lucho2027
@Lucho2027 8 ай бұрын
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
@abhijitbiradar
@abhijitbiradar Жыл бұрын
Many Thanks for very detailed explanation from scratch. It helped me a lot.
@user-fl1km1jq1d
@user-fl1km1jq1d 9 ай бұрын
awesome explanation
@NicoRitondale
@NicoRitondale Ай бұрын
ty for the video
@krishnai7637
@krishnai7637 Жыл бұрын
Great explanation, easy to understand, thank you
@techdose4u
@techdose4u Жыл бұрын
Welcome :)
@oyesaurabh
@oyesaurabh 10 ай бұрын
ok i understood but why we need to calculate 4, 9, 40, etc ?
@himanshusingla1189
@himanshusingla1189 Жыл бұрын
Amazing thanks for such a great explaination
@techdose4u
@techdose4u Жыл бұрын
Welcome :)
@dynamicgamerz3366
@dynamicgamerz3366 Жыл бұрын
Sir please make a proper video on Number to words
@akshaygoyal4118
@akshaygoyal4118 6 ай бұрын
91 is printing LCI since 90 is LC and remaining 1 is I which is wrong as per substraction mechanism it should be XCI
@anjanik7053
@anjanik7053 Жыл бұрын
Very nicely explained.. Thank You
@psyknyt
@psyknyt Жыл бұрын
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++; } }
@manashvardhan9965
@manashvardhan9965 Жыл бұрын
Shi dimag lagaye ho beta
@littlespark0
@littlespark0 10 ай бұрын
You got a new subscriber
@hiq8002
@hiq8002 Жыл бұрын
why didn't you take 10,000 next to 100,000 and directly went to 1000
@ramachandrank2491
@ramachandrank2491 Жыл бұрын
it was just an example , 10,000 wasn't an available notation in his example, thus something like 10084 had to be derived from an already available number in his notation like let's say 1000
@RaunakShrivastava
@RaunakShrivastava Жыл бұрын
Thank you for sharing coding videos. Can you please make videos on Low Level Design as well. :) Thanks again!
@AjithKumaR-jw9wt
@AjithKumaR-jw9wt Жыл бұрын
Bro you find any resources to learn low level design
@sirphiriladki5531
@sirphiriladki5531 5 ай бұрын
thank you so muchh
@pranaykumar562
@pranaykumar562 Жыл бұрын
Boss is back 🎉
@sayedkhalil5996
@sayedkhalil5996 Жыл бұрын
thank you that's great
@manashvardhan9965
@manashvardhan9965 Жыл бұрын
mja aa gya
@arnavkarforma3015
@arnavkarforma3015 Ай бұрын
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] 0){ sb.append(symbols[i]); repeat --; } } } return sb.toString(); } }
@Curiousss_Shivammm
@Curiousss_Shivammm 11 ай бұрын
For the division approach how do I add notations[pos] x times in roman string without for loop is there any other method.
@yourhonestbro217
@yourhonestbro217 3 ай бұрын
**Division method but the time is same only the memory is improved compared to Subtraction** while(input>0){ int divide = input/val[i]; if(divide > 0){ if(divide == 2) { sb.append(symbols[i]).append(symbols[i]); } else if(divide == 3){ sb.append(symbols[i]).append(symbols[i]).append(symbols[i]); } else sb.append(symbols[i]); input = input%val[i]; } else{ i++; } }
@gauravbankar4894
@gauravbankar4894 7 күн бұрын
And this question is from easy section 😂
@ShubhamKumar-km8pm
@ShubhamKumar-km8pm Жыл бұрын
How can we print the notation 'V' like 2 times or 3times or num/value[i] times.
@aditgulia272
@aditgulia272 11 ай бұрын
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.
@jayrathod9271
@jayrathod9271 7 ай бұрын
Just think in other way around. I want to make 50. So I can take 50 and 10 to make it which is minimal String
@vinitraj6268
@vinitraj6268 8 ай бұрын
Can u check for 1994
@BRAJESHKUMAR-lz4mw
@BRAJESHKUMAR-lz4mw Жыл бұрын
What is name of this white board software plz?
@DeepakSingh-xb6fq
@DeepakSingh-xb6fq Жыл бұрын
Which app do you use to create the video?
@Jaffar87
@Jaffar87 Жыл бұрын
solve all leetcode premium questions
@prasanthgudi562
@prasanthgudi562 Жыл бұрын
Any c++course available sir
@umidjonkosimov
@umidjonkosimov 11 ай бұрын
Why you dropped 10,000?
@rohit-ld6fc
@rohit-ld6fc Жыл бұрын
too long video for a medium problem
@chrissimpson214
@chrissimpson214 Жыл бұрын
ᑭяỖmo𝓼𝐦 👏
@jesuschristsaves1955
@jesuschristsaves1955 Жыл бұрын
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
@kanishkthegreat7993
@kanishkthegreat7993 Жыл бұрын
bhak bc, put your jesus where sun doesn't reach
@user-kh3qb1nf8x
@user-kh3qb1nf8x 11 ай бұрын
I think you forget to add 6 to your cpp code. Maybe I'm wrong. I can't find it. 17:04
Number of islands | Leetcode #200
12:44
Techdose
Рет қаралды 180 М.
Now it’s my turn ! 😂🥹 @danilisboom  #tiktok #elsarca
00:20
Elsa Arca
Рет қаралды 12 МЛН
The CUTEST flower girl on YouTube (2019-2024)
00:10
Hungry FAM
Рет қаралды 41 МЛН
So Cute 🥰
00:17
dednahype
Рет қаралды 45 МЛН
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 204 М.
Integer to Roman - Leetcode 12 - Python
9:43
NeetCode
Рет қаралды 70 М.
Python Program To Convert Given Integer To Roman Numerals | Programs
26:09
How to Start Leetcode (as a beginner)
8:45
Ashish Pratap Singh
Рет қаралды 851 М.
Medium Google Coding Interview With Ben Awad
51:27
Clément Mihailescu
Рет қаралды 1,3 МЛН
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 843 М.
Roman to Integer | Leetcode -13 | Algorithms Made Easy
5:22
Algorithms Made Easy
Рет қаралды 134 М.
DSA Phir se with Sumeet | Leetcode 12 | Integer to Roman
11:20
Pepcoding
Рет қаралды 3,4 М.
Now it’s my turn ! 😂🥹 @danilisboom  #tiktok #elsarca
00:20
Elsa Arca
Рет қаралды 12 МЛН