Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Example 1: Input: [2,2,1] Output:…
#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…