In 2020, it’s hard, life is hard, work is hard.

Said good brush algorithm, the results of three days fishing two days sun net, touch fish all day. Like a broken man…

A few days ago, the Nuggets introduced a “small goal,” a daily move, stretch the aging body, found himself moving.

This time there is this activity, while fresh strength, the algorithm brush up, not to write much good, when to make notes for yourself.

All right!

Start where the dream began — sum of two numbers, hahahahahaha


** Method 1: ** method of violent loop, two layer for loop, element sum is equal to the target value. Time complexity is not OK, abandon.

** Use the Hash algorithm to identify the map.containsKey based on the element as the key and the subscript as the value.


Problem number two — integer inversion

We simply take the last digit of the original number, and place the last digit in front of the value of the result, and so on until the original number is zero. To get the last digit, use %10, and then divide the original number by 10, so next time continue %10, and then divide by 10 again, creating a loop.

2^32~2^32-1 Need to be judged.

This topic in the comments section to see a big man’s solution, is very admire.

In this one, ans times 10 over 10 factorial. = ans*10, if it overflows, then it can’t be equal to the original number divided by 10. At the same time, if there is no overflow, and since the bottom x%10 cannot exceed 10, it can only be 0 to 9, ans*10 units digit is 0, so ans*10 + x%10 does not carry, nor does it overflow.

Bow down to the big guys!

Let’s stop here today and see you tomorrow