93.Restore IP Addresses

这题就是要寻找分割字符串的3个点的位置,假设用a=(a1,a2,a3)表示一组解,ai(i=1,2,3)分别表示第i点前面有几个字符,例如字符串“25525511137”中一个解为255.255.111.37这对应的解向量为a=(3,3,3);根据题意,可以知道ai可取的值只有1,2,3,依次尝试各个值,ai的取值组合构成了一颗解空间树,用DFS搜索这棵树得到所有可行解。

149.Max points on line

One intrinsic solution to this problem is to use three loops to traverse and find them all, during which we are going to find the line equation determined by two points and then check the last one in the innermost loop; but using two points to get the line equation is quite inconvenient and inefficient so we need to search for another method that can be used more easily - at last we find out determine whether three points in one line or not can simply determined by slope and one fixed point, by the way the slope must be calculated with the fixed point....

52.N-queens II

Obviously there are two quite different solutions to this problem though both of them are belonging to backtracking and both of them are using row-based method to reduce calculation burden - row-based traversing method which means we will check each row of the board in sequence and find the viable columns for them...