LeetCode Explained - Reverse Integer [EASIEST WAY]

preview_player
Показать описание
If you don't understand how Integer Overflow works then you NEED to watch this video! Hopefully this video helps you understand the algorithm needed to attack this question.

Getting ready for your next interview? Coding challenges got you frustrated? LeetCode Explained will help you understand all the popular coding interview questions! First we begin by deconstructing the problem into a statement we are able to understand easily.

This problem primarily tests your knowledge on Integers in the programming language of your choice. Even though this video is in Java, the solution will definitely transfer to all programming languages including: Python, C++, C#, Javascript, etc.

Then after that we start by writing it out just like how we would on a whiteboard. Next, after we come up with a written solution we begin coding. Throughout coding each step gets explained so you don't get confused.

Check out the problem here:

LeetCode Explained - Median of Two Sorted Arrays [HARD]
0:00 Whiteboard Walkthrough
4:28 Coding
6:06 Time Complexity
6:50 Outro

Tags: Java, learning to code, leetcode, algorithms, coding interview, coding challenge, programming, learning java, hard programming question, hacker rank, software engineer, software engineering, day in the life of a software engineer, how to code, median, arrays, binary search
Рекомендации по теме
Комментарии
Автор

The time complexity of this is actually O(log(N)). This is because there are roughly log_10(N) digits in the number.

Conner.Wallace
Автор

the way you used Two's compliment is quite elegant to handle the overflow/underflow

cvxcfv
Автор

dude this helped so much and was so easy to understand. it was awesome man

Ethan-krce
Автор

I write out everything you say so i can explain it like this in a technical interview!!

jazzhippie
Автор

I feel like you will be experiencing an overflow before comparing result with prev, and you will lose your number. Plus I'm not so sure how you managed to pass the negative test cases, because negative mod only works with -10. I copied the exact same code of yours but it couldn't pass the negative test cases

CC-dkdi
Автор

Hello, I am confused . I understand that 1234 mod 10 is 4, then you say to divide 1234 by 10 to get 123 and mod it by ten to get 3 . But 1234 / 10 = 123.4 ? Then you mod 123.4 and 10 and get 3.4.... what am I getting wrong please help thanks

jayhun
Автор

I don't get if statement can u explain

sanjulagoyal
Автор

How -8-1 becomes -9? with 4 bits you can only represent the numbers -8 to +7

sagyas