Technical Interview Question - Reverse Integer [LeetCode]

preview_player
Показать описание
Check out my interview prep platform for learning the patterns!

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

Thank you for solution, but I would not use a long variable because leetcode says "Assume the environment does not allow you to store 64-bit integers (signed or unsigned).". I prefer checking overflow before calculating the result as follows:

bool multiply_overflows = result > INT_MAX / 10;
bool multiply_underflows = result < INT_MIN / 10;

if(multiply_overflows || multiply_underflows ) {
return 0;
}

raphael.goncalves
Автор

Really clever trick of using "long" instead of "int".

Just a doubt, how are the negative intergers handled via your approach.

kunal_chand
Автор

Why don’t you just convert into string and use a stack?

hamaso
Автор

If I practice DSA with Swift for 3 months, 6 hours daily? M I ready t9 get entry level job at apple??

tech_wizard
join shbcf.ru