Add Digits | With Proof | (MICROSOFT, ADOBE) | Leetcode-258 | Live Code + Explanation

  Рет қаралды 1,941

codestorywithMIK

codestorywithMIK

Күн бұрын

This is the 4th Video on our Maths Playlist.
In this video we will try to solve a very good and interesting Problem "Add Digits" (Leetcode - 258)
We will do live coding after explanation and see if we are able to pass all the test cases.
Problem Name : Add Digits
Company Tags : MICROSOFT, ADOBE
My solutions on Github : github.com/MAZ...
Leetcode Link : leetcode.com/p...
My GitHub Repo for interview preparation : github.com/MAZ...
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish

Пікірлер: 39
@codeandtalk6
@codeandtalk6 Жыл бұрын
2nd approach was 😮 ❤
@aryabhishekverma
@aryabhishekverma Жыл бұрын
yes but why was leetcode showing that the first approach is faster than 100%?
@mar-cosgupta7330
@mar-cosgupta7330 3 ай бұрын
Gjb
@gautamarora6556
@gautamarora6556 Жыл бұрын
Tips: • Any number which is divisible by 9 has the sum of digits adding up to 9 always. • Therefore, the digital root for any number divisible by 9 is always 9. • The digital root (ans) for 0 is always 0. • For any number that isn't 0 and isn't divisible by 9, the digital root (ans) will always be n % 9, where n is the given number. • This is because the difference between the given number and the nearest number that is divisible by 9 will always be a multiple of 9, and therefore have a digital root of 9. • This algorithm skips the "add digits until there is only 1 remaining" method for finding the digital root. • The Leetcode problem may be misleading in its description, but it is important to learn all of these tricks.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Amazing ❤️
@anuppatankar4294
@anuppatankar4294 Жыл бұрын
Second approach was awesome 👌🏻
@prabhkiratsingh8490
@prabhkiratsingh8490 Жыл бұрын
It has been four months since I started following your channel. Amazing content🔥 Would it be possible for you to start uploading GFG POTD as well? It would be really helpful.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you so much Prabhkirat ❤️ I have not yet planned GFG POTD due to time constraints but soon i will be trying to cover them too. Because the qns are good there too
@prabhkiratsingh8490
@prabhkiratsingh8490 Жыл бұрын
@@codestorywithMIK Sure 👍, BTW it's Prabhkirat*
@codestorywithMIK
@codestorywithMIK Жыл бұрын
So sorry for the typo. Corrected the spelling. Thank you for visiting my channel ❤️❤️❤️
@prabhkiratsingh8490
@prabhkiratsingh8490 Жыл бұрын
@@codestorywithMIK No issues Bro ❣❣You are doing a great job👍I'm glad I found this gem on KZbin.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
❤️❤️❤️
@good114
@good114 Жыл бұрын
💗❤️
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
you are a master
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
Always learning from you
@NishantSingh-br6iu
@NishantSingh-br6iu Жыл бұрын
Optimal Approach was 🔥🔥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
🙏😇
@ankitsingh6624
@ankitsingh6624 Жыл бұрын
🔥 Always learn something
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot ❤️
@jameskurakula3250
@jameskurakula3250 Жыл бұрын
Nice explanation 👍
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks James ❤️❤️❤️
@ghayoorhussain8930
@ghayoorhussain8930 Жыл бұрын
Thank You Soo Much Sir
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot ❤️
@YashSinghal
@YashSinghal Жыл бұрын
other way of doing the same logic brute force: int sumDigits(int num){ int sum = 0; while(num>9){ sum += num%10; num = num/10; } return sum+num; } int addDigits(int num){ while(num>9){ num = sumDigits(num); } return num; }
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
Nice
@YashSinghal
@YashSinghal Жыл бұрын
@@souravjoshi2293 ty :)
@rahulmaurya6451
@rahulmaurya6451 Жыл бұрын
Why optimal approach is Taking more time than Brute Force ?
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Sometimes it happens on leetcode. Try submitting multiple times, it sometimes shows 100% and sometimes not.
@manimanohar_001
@manimanohar_001 Жыл бұрын
BTW remainder leetcode 92
@elakstein
@elakstein Жыл бұрын
11:50 how can we say it as =9*constant + Sd. the part we are multiplying with 9 contains d0,d1 etc they aren't constant.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
The part where all terms are multiplied by 9 , if you take 9 common, then other remaining terms will sum up to some number . Which we can denote as some constant K may be. Yes, the value will be different every time, but the crux is that 9 can be taken out common .
@pritishpattnaik4674
@pritishpattnaik4674 Жыл бұрын
Bhaiya , I have a doubt , this is off topic , can u please make a video about the conversions like char to int , int to char by adding or subtracting 0 or subtracting or adding a or 0 like that , I always get confuised in those things , please help sir
@codestorywithMIK
@codestorywithMIK Жыл бұрын
That’s a wonderful idea. Can you please remind me this weekend about this ❤️
@pritishpattnaik4674
@pritishpattnaik4674 Жыл бұрын
@@codestorywithMIK yes sir sure
@manimanohar_001
@manimanohar_001 Жыл бұрын
Bro notification nhi aarha hai aapke channel ka
@codestorywithMIK
@codestorywithMIK Жыл бұрын
I think you will have to press the Bell Icon and select All from the options.
@manimanohar_001
@manimanohar_001 Жыл бұрын
@@codestorywithMIK hua pada hai bro phir bhi nhi aarha hai
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hmm strange. Not sure. May b glitch from KZbin
小丑和白天使的比试。#天使 #小丑 #超人不会飞
00:51
超人不会飞
Рет қаралды 43 МЛН
Introduction to C Language (Hindi) | What is C? full Explanation
20:17
Learn Coding
Рет қаралды 1,1 МЛН
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,6 МЛН
Higher-Order Components Are Misunderstood In React
17:38
Jan Hesters
Рет қаралды 1,1 М.
Google Coding Interview With A Competitive Programmer
54:17
Clément Mihailescu
Рет қаралды 2,5 МЛН
Word Pattern -(Amazon, MakeMyTrip, Microsoft) : Explanation ➕ Live Coding
28:34