Convert Integer to Roman numeral - LeetCode Interview Coding Challenge [Java Brains]

  Рет қаралды 64,483

Java Brains

Java Brains

Күн бұрын

Пікірлер: 76
@suseelkumarannamraju
@suseelkumarannamraju 3 жыл бұрын
After so many days, I recollected my childhood days, where I use to play with Roman numbers, but completely forget when days have grown. Now it's because of u, I recollected them and felt enjoying by looking at your video. Thank you so much sir.
@tanaypatel8412
@tanaypatel8412 2 жыл бұрын
Saiman says teaching java, amazing...
@rutvij2811
@rutvij2811 4 жыл бұрын
As you have said in the end, sometimes we complicate fairly simple tasks. I was thinking about using switch case , hashmap and whatnot before I saw your approach to the question. Amazing explanation.
@elainelopes7043
@elainelopes7043 3 жыл бұрын
Zvgdbdgsbshdbhysdhvxgdgebebsyydhnxnxnhybxsbsnh hj d vc TB hj
@elainelopes7043
@elainelopes7043 3 жыл бұрын
Bvgz gsbhggbevgrhvfgggstztyyggf Gv Nnjbdbsbshs7dududuuddduydyydydd7yhyxyyddhhdd6hhhshdyhvhdhnjfbhhghhfgedbzgfbdehhdhejbznzhshsjsshbjnshbzb um yt
@SatyamKumar-bw4vi
@SatyamKumar-bw4vi 2 жыл бұрын
same with me
@abhinav9469
@abhinav9469 5 жыл бұрын
Thanks for sharing this gem. If I had not gone through this video I would have chosen a much complex approach to solve this. This solution teaches that for some 'COMPLEX-SOUNDING' problems. A simple and feasible solution exists. All we need is to stick to the basics... Thanks again for this wonderful tutorial Kaushik..God bless you.
@geovanny_alfaro
@geovanny_alfaro 5 жыл бұрын
This is such a great video, I remember the first time I encountered it in school. I went a different more convoluted route.
@ADGroupOfArtMedia1
@ADGroupOfArtMedia1 5 жыл бұрын
Yeeee! I love you Man! Thanks a ton for every contribution you made in my career!
@kirant5548
@kirant5548 3 жыл бұрын
One of the best optimised solution for int to roman conversion. your just awesome man
@FBHI
@FBHI Жыл бұрын
And here I was so proud of my code: "int unit = value % 10; value /= 10; int dozen = value % 10; value /= 10; int cent = value %10; value /= 10; int mil = value %10; value /= 10; return thousands[mil]+hundreds[cent]+tens[dozen]+units[unit];" Lot of repeated stuff honest work, then I saw the video results..... sooo much to learn =/
@sureshgarine
@sureshgarine 3 жыл бұрын
wow! what a nice thinking process. many KZbinrs share logic, but to my surprise, you speak about the thought process. Thank you so much sir. can you please make leetcode playlist for all the medium level problems
@monsterhuntergo
@monsterhuntergo 2 жыл бұрын
Amazing! my Primary-2 kid actually have this Math topic of ones, tens, and hundreds.. This is an amazing solution. Thanks so much sensei Kaushik. :)
@preethialbert9652
@preethialbert9652 4 жыл бұрын
Please do more of these type of problems. Your explanation is very good and clear. Expecting more like this
@shrad6611
@shrad6611 2 жыл бұрын
thumbs up :), and sorry for prev comment on last video
@vinayprasad4659
@vinayprasad4659 5 жыл бұрын
Wow. I did not know you started sharing leetcode questions. This is awesome. Is there a playlist?
@Java.Brains
@Java.Brains 5 жыл бұрын
Thanks! Here you go: kzbin.info/aero/PLqq-6Pq4lTTZgXnsBNQwCWdKR6O6Cgk1Z Not a lot yet, but there will be more coming up. Make sure you are subscribed with notifications if you don't want to miss out! :)
@vinayprasad4659
@vinayprasad4659 5 жыл бұрын
This is super awesome Koushik. Thanks for sharing. Your videos have helped me for years. You make extremely complicated things very simple. I will keep looking for this space.
@madhug82
@madhug82 3 жыл бұрын
super one Kaushik. the approach you take to these problems is very intuitive . Thanks for this video.
@hunterlive2434
@hunterlive2434 3 жыл бұрын
Greetings from Russia. Thanks!
@aleksapetrovic6519
@aleksapetrovic6519 2 жыл бұрын
Interesting. I tought we would need to do the parse at one point. This is an excellent solution.
@bhaminisundararaman6080
@bhaminisundararaman6080 2 жыл бұрын
wow...my solution was....quite....extensive..... thank you for this lol
@shuchivarshney3191
@shuchivarshney3191 4 жыл бұрын
@Java Brains - Super Awesome..!! I like the "what kind of questions you can ask from Interviewer" part of your video, this usually youtuber don't tell it. Please go ahead with Leetcode series.
@cdhagen
@cdhagen 5 жыл бұрын
Your videos keep getting better and better. Kudos!
@OzWannabe
@OzWannabe 5 жыл бұрын
This will work up to 3000. You can make it work easy up to 10000 or to max_value from short (just don't pass int as argument as this can go from -2147483647 to +2147483647to . What Romans did was to add a line over a number meaning they were multiplying that number by 1000. So, if you needed to write 9000 you had IX with a line over it. So for a max short (32768) you would have the tens of thousands XXX with a line over it and then use your function to append to it.
@metamike_23
@metamike_23 Жыл бұрын
I just answered this question on leetcode and it took me 95 lines of code to get a solution
@nerodant85
@nerodant85 2 жыл бұрын
Thank you so much for making the question so easy to understand
@SaurabhkrGupta-tc7qs
@SaurabhkrGupta-tc7qs 4 жыл бұрын
Thanks for the great explaination Kaushik. Kudos to you
@Impromptu21
@Impromptu21 3 жыл бұрын
Nyc one sir
@VinitKumar_Vinigem
@VinitKumar_Vinigem 5 жыл бұрын
Thanks for sharing these.
@kbhargavi4400
@kbhargavi4400 3 жыл бұрын
Amazing sir!! Truly most clear explanation! : )
@ashvajitchauhan608
@ashvajitchauhan608 5 жыл бұрын
Very helpful, It would be appreciable if you make video on cache mechanism in spring and software perform. Thanks in advance
@meeknkosi
@meeknkosi 3 жыл бұрын
you explain so perfectly
@vocipy2068
@vocipy2068 2 жыл бұрын
When Roman Numerals were invented, there was no concept of Zero, and nobody had yet thought about negative numbers as a concept.
@NareshKumar-dw9xp
@NareshKumar-dw9xp 4 жыл бұрын
Why do I have a fear while watching your video like you are my interviewer and I am the student ? LOL :) Videos are always awesome btw
@SuperYouthful
@SuperYouthful 4 жыл бұрын
Int Roman = input(); Int divide = 0; Int thousand; Int fiveHundred; Int oneHundred; Int fifty; Int ten; Int five; Int one; Thousand = Roman / 1000; Divide = Roman - 1000* Thousand; FiveHundred = Divide /500; Divide = Divide - 500 * FiveHundred; OneHundred = Divide /100; Divide = Divide - 100* Onehundred; Continue for 50 and 10 and 5 and 1... If (onethousand > 0){ For (i=onethousand, i--, i>0) System.out.print("M"); Continue for the REST OF the Num.
@shubhamsaurabh4419
@shubhamsaurabh4419 5 жыл бұрын
Thanks you so much sir!!! This solution is amazing!!! Wonderful!!! Maja aa gaya. In the beginning i thought that this is a very tough question but the way you solve it and the solution is no doubt amazing!!! Thanks once again sir...
@raman2192
@raman2192 5 жыл бұрын
Nice one
@namratam1522
@namratam1522 5 жыл бұрын
Please try uploading more and more algorithmic questions where getting logic is difficult. Example: sliding window alogos etc.
@krishanuchakraborty3500
@krishanuchakraborty3500 5 жыл бұрын
Thanks a ton for this video, I love the way you explain the concepts, would request you to add more such unique Java Interview question videos to this series. Thanks.
@analogylibrary
@analogylibrary 5 жыл бұрын
Greatly explained!!
@MaheshBabu-ys3vh
@MaheshBabu-ys3vh 4 жыл бұрын
Hi Koushik, First of all, thank you for all your lectures. Your video quality is excellent. Would you like to put list of resources you use for the video making? It will help a lot for starters like me who interested to start a youtube channel. Tools like what whiteboard app you are using, are you using apple pencil etc. Also if you have any affiliate links, Please provide them. We can use those links to purchase that help your channel too. Thanks Mate
@Satya-g5t
@Satya-g5t 14 күн бұрын
On the lighter side, this problem is negating the famous saying "While in Rome, do as Romans do", just the nature of problem itself, not your solution, your solution is good. 😄
@tarmagoyf95
@tarmagoyf95 5 жыл бұрын
Hi, romans didn't have the concept of negative numbers, the only use natural numbers without the 0 number
@dance_with_shivangi.
@dance_with_shivangi. 4 жыл бұрын
Your voice is like sundar pichai
@MadhusudanBhosale
@MadhusudanBhosale 5 жыл бұрын
Amazing logic, Sir! ✌
@saddamahmad2310
@saddamahmad2310 5 жыл бұрын
thank you very much sir for this video
@wdwuccnxcnh7022
@wdwuccnxcnh7022 3 жыл бұрын
Thanks man!
@soumavanag5025
@soumavanag5025 3 жыл бұрын
Thanks :)
@vihangafernando6644
@vihangafernando6644 2 жыл бұрын
Hi sir i'm an intern SE and I have been following your content for sometimes. It took me more than 6hrs to complete this question. How can I improve my skills on these type of questions.I'll attach my code in another comment . Thank you for you content. Guidance from the community would be also nice :).
@vihangafernando6644
@vihangafernando6644 2 жыл бұрын
public class Calculator { public static void main(String[] args) { String s = integerToRoman(1994); System.out.println(s); } private static String integerToRoman(int input) { int[] intArr = {1,4, 5, 9,10,40, 50,90, 100,400, 500, 900,1000}; int module = 0; int value = input; StringBuilder stringBuilder = new StringBuilder(""); for (int index = intArr.length - 1; index >= 0; index--) { module = value / intArr[index]; stringBuilder.append(stringGenerator(index,module)); value = value- module* intArr[index]; } return stringBuilder.toString(); } private static String stringGenerator(int index, int module) { String[] romanArr = {"I","IV", "V","IX", "X", "XL","L","XC", "C","CD" ,"D","CM", "M"}; String s = ""; for (int i = 0; i < module; i++) { s = s + romanArr[index]; } return s; } }
@kartikmahendrajalal5660
@kartikmahendrajalal5660 4 жыл бұрын
Thanks, bro
@רפאלבלזם-לבנון
@רפאלבלזם-לבנון 3 жыл бұрын
I love your chanel, Thank you very much for the content. About this question, the answer you gave is not correct, for example 499 in roman is "ID" but your code returns "CDXCIX".
@adolfocarrillo248
@adolfocarrillo248 2 жыл бұрын
NoUuuuuuuu, your´re wrong, He´s right🤥
@mayoorm909
@mayoorm909 5 жыл бұрын
👌
@TheDheerendraJaiswal
@TheDheerendraJaiswal 5 жыл бұрын
Hello sir, waiting for your oauth2 tutorials..
@keshavendraps
@keshavendraps 5 жыл бұрын
950 should be CML or LM?
@dangels666
@dangels666 4 жыл бұрын
CML
@joetorres4933
@joetorres4933 3 жыл бұрын
The first array value of units has a “ not a ".
@ameyamahadevgonal8130
@ameyamahadevgonal8130 3 жыл бұрын
At the start of the problem it looked like a mount everest but after the explanation it looked look nothing
@meenakshibhatia2537
@meenakshibhatia2537 5 жыл бұрын
How do you get the index as the actual digit? Index would be 0,1,2,3 and so on.
@dangels666
@dangels666 4 жыл бұрын
Because for 0th index he is storing empty value. hence for each index correct value is picked up. if you don't store empty index at first, then you would have to fetch by array[index -1]
@snehanair2246
@snehanair2246 3 жыл бұрын
can u also mention the time and space complexity please?
@soumavanag5025
@soumavanag5025 3 жыл бұрын
t(n) = o(number of digits in n)
@Mohit-il9gx
@Mohit-il9gx 3 жыл бұрын
6:10 i did 🤣
@by-Org
@by-Org 2 жыл бұрын
why didn't you end
@NitinSinghMinVlogs
@NitinSinghMinVlogs 3 жыл бұрын
lol this question😂😂😂
@ZhouHaibo
@ZhouHaibo 3 жыл бұрын
Wow, but this solution is slow, just beat 20% of other solutions in Java. Maybe too many calculations in return result that slow.
@emanresplandor3878
@emanresplandor3878 4 жыл бұрын
wow we have somewhat the same solution wtf..
@ZhouHaibo
@ZhouHaibo 3 жыл бұрын
That is O(1) time and O(1) space, you are cheating, men:)
@victorseba6410
@victorseba6410 4 жыл бұрын
U kinda talk a lot
@FredOooUnavailable
@FredOooUnavailable 3 жыл бұрын
Why don't you use an array of array where the first level is indexed by p = [0, 1, 2, 3] that you can use as [10**0, 10**1, 10**2, 10**3] = [1, 10, 100, 1000] ? So if you loop on p--, you can get every thing with romans[ p ][ num / 10**p ]
Detect Capital - LeetCode Interview Coding Challenge [Java Brains]
25:09
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
What is JWT? JSON Web Tokens Explained (Java Brains)
14:53
Java Brains
Рет қаралды 1 МЛН
Integer to Roman | Leetcode #12
17:34
Techdose
Рет қаралды 44 М.
Amazon Coding Interview Question - Integer to Roman (LeetCode)
9:06
AlgosWithMichael
Рет қаралды 21 М.
5 interview techniques to show problem solving skills
17:23
Java Brains
Рет қаралды 11 М.
Roman to Integer - Leetcode 13 - Python
7:57
NeetCode
Рет қаралды 179 М.
What is OAuth really all about - OAuth tutorial - Java Brains
10:56