摘要: public class Solution { public void reverse(int[] nums, int start, int end) { while (start < end) { int temp = nums[start]; nums[start] = nums[end]; n 阅读全文
posted @ 2017-04-26 21:45 Sempron2800+ 阅读(124) 评论(0) 推荐(0) 编辑
摘要: /* The isBadVersion API is defined in the parent class VersionControl. bool IsBadVersion(int version); */ public class Solution : VersionControl { pub 阅读全文
posted @ 2017-04-26 20:39 Sempron2800+ 阅读(87) 评论(0) 推荐(0) 编辑
摘要: public class Solution { private string Convert(int k) { var s = ""; switch (k) { case 1: s = "A"; break; case 2: s = "B"; break; case 3: s = "C"; brea 阅读全文
posted @ 2017-04-26 19:51 Sempron2800+ 阅读(106) 评论(0) 推荐(0) 编辑
摘要: public class Solution { Stack<char> S = new Stack<char>(); Queue<char> Q = new Queue<char>(); public bool IsPalindrome(string s) { if (s.Length == 0) 阅读全文
posted @ 2017-04-26 19:16 Sempron2800+ 阅读(131) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int MySqrt(int x) { long r = x; while (r * r > x) r = (r + x / r) / 2; return (int)r; } } https://leetcode.com/problems 阅读全文
posted @ 2017-04-26 18:58 Sempron2800+ 阅读(210) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/count-primes/#/description 这道题目是意思是,计算比n小的非负数中有多少素数。 例如: n = 7,素数有2,3,5(不包含7)一共3个 n = 8,素数有2,3,5,7一共4个 使用素数筛法可以提高效率。 pyt 阅读全文
posted @ 2017-04-26 18:50 Sempron2800+ 阅读(124) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/third-maximum-number/#/description 阅读全文
posted @ 2017-04-26 18:14 Sempron2800+ 阅读(102) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/k-diff-pairs-in-an-array/#/description 阅读全文
posted @ 2017-04-26 18:04 Sempron2800+ 阅读(88) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/implement-strstr/#/description python实现,不实用内置函数: 作为一道easy题目,提交成功率只有33%,可以看出本题的一些细节需要仔细分析,否则很容易出错。 阅读全文
posted @ 2017-04-26 17:27 Sempron2800+ 阅读(103) 评论(0) 推荐(0) 编辑
摘要: public class MinStack { Stack<int> S = new Stack<int>(); /** initialize your data structure here. */ int min = int.MaxValue; public MinStack() { } pub 阅读全文
posted @ 2017-04-26 17:22 Sempron2800+ 阅读(123) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/range-sum-query-immutable/#/description 补充一个python的实现: 阅读全文
posted @ 2017-04-26 16:51 Sempron2800+ 阅读(98) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public uint reverseBits(uint n) { var list = new List<uint>();//逆序的二进制列表,list[0]是最低位 while (n != 0) { var cur = n % 2; list.Ad 阅读全文
posted @ 2017-04-26 16:32 Sempron2800+ 阅读(114) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/heaters/#/description 阅读全文
posted @ 2017-04-26 16:16 Sempron2800+ 阅读(139) 评论(0) 推荐(0) 编辑