Summary of ideas for solving algorithm problems

1. Familiarize yourself with the programming language you know. For example, if I use java, I need to be proficient in the language details of java.

When encountering such a problem, given an array containing n integers, except for one integer, the rest of the numbers are in pairs, please find this number (time complexity O(n), no additional storage space can be used ). For example [1,2,2], then the result is 1.

When I first encountered this problem, I didn't think that it could be solved by XOR. If you are just starting to get in touch with algorithms, you really can't think of a solution if you really want to break your head.

So if you encounter problems, start with the language level. Check out the grammar details to see if they can inspire you to solve the problem.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324729854&siteId=291194637