摘要:
Implement Pow(x, n) 1 public static double Pow(double x, int n) 2 { 3 bool is_neg = n < 0; 4 5 //Because Math.Abs(int.MinValue) not exist. 6 if (n == int.MinValue) 7 { 8 return 1 / Pow(x, int.MaxValue) * x; 9 ... 阅读全文
摘要:
Given a number represented as an array of digits, plus one to the number. 1 public static List<int> PlusOne(List<int> digits) 2 { 3 int carry = 1; 4 for (int i = digits.Count - 1; i >= 0; i--) 5 { 6 digits[i] = digits[i] + carry; 7 ... 阅读全文
摘要:
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1]. 1 public static List<List<int>> PermutationsII(List<int> num) 2 { 3 List<List<int... 阅读全文