#include "000库函数.h" //使用折半算法 牛逼算法 class Solution { public: double myPow(double x, int n) { if (n == 0)return 1; double res = 1.0; for (int i = n; i != 0; i /= 2) { if (i % 2 != 0) res *= x; x *= x; } return n > 0 ? res : 1 / res; } }; //同样使用二…
Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.With each iteration one element (red) is removed from the input data and inserted in…
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Example 1: Input: [[1,1],[2,2],[3,3]] Output: 3 Explanation: ^ | | o | o | o +-------------> 0 1 2 3 4 Example 2: Input: [[1,1],[3,2]…