leetcode413
摘要:https://leetcode.com/problems/arithmetic-slices/#/description 补充一个java的实现: 解释: dp[i] 表示以 A[i] 为结尾的等差递增子区间的个数。 因为递增子区间不一定以最后一个元素为结尾,可以是任意一个元素结尾,因此需要返回
阅读全文
posted @
2017-04-29 23:57
Sempron2800+
阅读(116)
推荐(0)
leetcode513
摘要:https://leetcode.com/problems/find-bottom-left-tree-value/#/description
阅读全文
posted @
2017-04-29 23:42
Sempron2800+
阅读(107)
推荐(0)
leetcode338
摘要:https://leetcode.com/problems/counting-bits/#/description 另一个版本,246ms: 补充一个使用动态规划思想的代码,使用python实现:
阅读全文
posted @
2017-04-29 22:58
Sempron2800+
阅读(139)
推荐(0)
leetcode419
摘要:https://leetcode.com/problems/battleships-in-a-board/#/description
阅读全文
posted @
2017-04-28 23:14
Sempron2800+
阅读(88)
推荐(0)
leetcode537
摘要:https://leetcode.com/problems/complex-number-multiplication/#/description
阅读全文
posted @
2017-04-28 14:48
Sempron2800+
阅读(109)
推荐(0)
leetcode535
摘要:https://leetcode.com/problems/encode-and-decode-tinyurl/#/description
阅读全文
posted @
2017-04-28 14:24
Sempron2800+
阅读(142)
推荐(0)
leetcode189
摘要: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+
阅读(143)
推荐(0)
leetcode278
摘要:/* 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+
阅读(94)
推荐(0)
leetcode168
摘要: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+
阅读(112)
推荐(0)
leetcode125
摘要: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+
阅读(141)
推荐(0)
leetcode69
摘要: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+
阅读(218)
推荐(0)
leetcode204
摘要: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+
阅读(134)
推荐(0)
leetcode414
摘要:https://leetcode.com/problems/third-maximum-number/#/description
阅读全文
posted @
2017-04-26 18:14
Sempron2800+
阅读(108)
推荐(0)
leetcode532
摘要:https://leetcode.com/problems/k-diff-pairs-in-an-array/#/description
阅读全文
posted @
2017-04-26 18:04
Sempron2800+
阅读(95)
推荐(0)
leetcode28
摘要:https://leetcode.com/problems/implement-strstr/#/description python实现,不实用内置函数: 作为一道easy题目,提交成功率只有33%,可以看出本题的一些细节需要仔细分析,否则很容易出错。
阅读全文
posted @
2017-04-26 17:27
Sempron2800+
阅读(122)
推荐(0)
leetcode155
摘要: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+
阅读(133)
推荐(0)
leetcode303
摘要:https://leetcode.com/problems/range-sum-query-immutable/#/description 补充一个python的实现:
阅读全文
posted @
2017-04-26 16:51
Sempron2800+
阅读(106)
推荐(0)
leetcode190
摘要: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+
阅读(128)
推荐(0)
leetcode475
摘要:https://leetcode.com/problems/heaters/#/description
阅读全文
posted @
2017-04-26 16:16
Sempron2800+
阅读(147)
推荐(0)
leetcode400
摘要:https://leetcode.com/problems/nth-digit/#/description
阅读全文
posted @
2017-04-25 23:48
Sempron2800+
阅读(332)
推荐(0)
leetcode160
摘要:https://leetcode.com/problems/intersection-of-two-linked-lists/#/description 补充一个python的实现:
阅读全文
posted @
2017-04-25 14:41
Sempron2800+
阅读(204)
推荐(0)
leetcode14
摘要:public class Solution { public string LongestCommonPrefix(string[] strs) { if (strs.Length == 0) { return ""; } else if (strs.Length == 1) { return st
阅读全文
posted @
2017-04-25 13:07
Sempron2800+
阅读(148)
推荐(0)
leetcode67
摘要:public class Solution { public string AddBinary(string a, string b) { var list = new List<string>(); if (a.Length > b.Length) { //补充b的长度 var dif = a.L
阅读全文
posted @
2017-04-25 12:02
Sempron2800+
阅读(134)
推荐(0)
leetcode58
摘要:C#的实现: public class Solution { public int LengthOfLastWord(string s) { s = s.Trim(); if (s.Length == 0 || s.Trim().Length == 0) { return 0; } var len
阅读全文
posted @
2017-04-25 11:38
Sempron2800+
阅读(114)
推荐(0)
leetcode203
摘要:https://leetcode.com/problems/remove-linked-list-elements/#/description
阅读全文
posted @
2017-04-25 11:27
Sempron2800+
阅读(119)
推荐(0)
leetcode88
摘要:public class Solution { public void Merge(int[] nums1, int m, int[] nums2, int n) { //for (int i = 0; i < n; i++) //{ //nums1[m++] = nums2[i]; //} //n
阅读全文
posted @
2017-04-25 10:21
Sempron2800+
阅读(127)
推荐(0)
leetcode219
摘要:https://leetcode.com/problems/contains-duplicate-ii/#/description
阅读全文
posted @
2017-04-25 09:28
Sempron2800+
阅读(111)
推荐(0)
leetcode225
摘要:https://leetcode.com/problems/implement-stack-using-queues/#/description
阅读全文
posted @
2017-04-24 22:39
Sempron2800+
阅读(129)
推荐(0)
leetcode234
摘要:https://leetcode.com/problems/palindrome-linked-list/#/description 补充一个python的实现:
阅读全文
posted @
2017-04-24 22:16
Sempron2800+
阅读(142)
推荐(0)
leetcode290
摘要:https://leetcode.com/problems/word-pattern/#/description
阅读全文
posted @
2017-04-24 22:03
Sempron2800+
阅读(119)
推荐(0)
leetcode111
摘要:/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNod
阅读全文
posted @
2017-04-24 21:34
Sempron2800+
阅读(133)
推荐(0)
leetcode507
摘要:https://leetcode.com/problems/perfect-number/#/description
阅读全文
posted @
2017-04-24 20:57
Sempron2800+
阅读(119)
推荐(0)
leetcode20
摘要:public class Solution { Stack<char> S = new Stack<char>(); public bool IsValid(string s) { foreach (var c in s) { if (c == '(' || c == '[' || c == '{'
阅读全文
posted @
2017-04-24 20:42
Sempron2800+
阅读(180)
推荐(0)
leetcode205
摘要:https://leetcode.com/problems/isomorphic-strings/#/description
阅读全文
posted @
2017-04-24 19:31
Sempron2800+
阅读(109)
推荐(0)
leetcode438
摘要:https://leetcode.com/problems/find-all-anagrams-in-a-string/#/description 上面的是别人在讨论区的实现。 下面是我自己的实现,使用非递归方法,性能更好:
阅读全文
posted @
2017-04-24 17:54
Sempron2800+
阅读(187)
推荐(0)
leetcode563
摘要:https://leetcode.com/problems/binary-tree-tilt/#/description
阅读全文
posted @
2017-04-24 15:00
Sempron2800+
阅读(109)
推荐(0)
leetcode561
摘要:https://leetcode.com/problems/array-partition-i/#/description
阅读全文
posted @
2017-04-24 11:47
Sempron2800+
阅读(98)
推荐(0)
leetcode112
摘要:/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNod
阅读全文
posted @
2017-04-22 17:56
Sempron2800+
阅读(126)
推荐(0)
leetcode38
摘要:public class Solution { public string CountAndSay(int n) { //1 //11 //21 //1211 //111221 //312211 //13112221 //1113213211 if (n == 1) { return "1"; }
阅读全文
posted @
2017-04-22 17:49
Sempron2800+
阅读(135)
推荐(0)
leetcode374
摘要:https://leetcode.com/problems/guess-number-higher-or-lower/#/description
阅读全文
posted @
2017-04-22 16:35
Sempron2800+
阅读(91)
推荐(0)
leetcode9
摘要:public class Solution { public bool IsPalindrome(int x) { if (x < 0) { return false; } var str = x.ToString(); var list = new List<string>(); foreach
阅读全文
posted @
2017-04-22 16:01
Sempron2800+
阅读(112)
推荐(0)
leetcode172
摘要:public class Solution { public int TrailingZeroes(int n) { if (n == 0) { return 0; } else { var x = n / 5; var y = TrailingZeroes(x); return x + y; }
阅读全文
posted @
2017-04-22 10:45
Sempron2800+
阅读(102)
推荐(0)
leetcode26
摘要:public class Solution { public int RemoveDuplicates(int[] nums) { var len = nums.Length; if (len == 0) { return 0; } else { var pre = nums[0]; var dif
阅读全文
posted @
2017-04-22 10:26
Sempron2800+
阅读(138)
推荐(0)
leetcode141
摘要:https://leetcode.com/problems/linked-list-cycle/#/description 补充一个python的版本:
阅读全文
posted @
2017-04-22 10:11
Sempron2800+
阅读(153)
推荐(0)
leetcode232
摘要:https://leetcode.com/problems/implement-queue-using-stacks/#/description
阅读全文
posted @
2017-04-22 09:55
Sempron2800+
阅读(113)
推荐(0)
leetcode119
摘要:public class Solution { public IList<int> GetRow(int rowIndex) { List<List<int>> list = new List<List<int>>(); for (int i = 0; i <= rowIndex; i++) { v
阅读全文
posted @
2017-04-22 08:41
Sempron2800+
阅读(115)
推荐(0)
leetcode441
摘要:https://leetcode.com/problems/arranging-coins/#/description
阅读全文
posted @
2017-04-21 22:05
Sempron2800+
阅读(83)
推荐(0)
leetcode110
摘要:/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNod
阅读全文
posted @
2017-04-21 19:21
Sempron2800+
阅读(122)
推荐(0)
leetcode257
摘要:https://leetcode.com/problems/binary-tree-paths/#/description
阅读全文
posted @
2017-04-21 17:50
Sempron2800+
阅读(135)
推荐(0)
leetcode434
摘要:https://leetcode.com/problems/number-of-segments-in-a-string/#/description
阅读全文
posted @
2017-04-21 17:29
Sempron2800+
阅读(104)
推荐(0)
leetcode118
摘要:public class Solution { public IList<IList<int>> Generate(int numRows) { var list = new List<IList<int>>(); for (int i = 0; i < numRows; i++) { var ro
阅读全文
posted @
2017-04-21 17:17
Sempron2800+
阅读(134)
推荐(0)
leetcode66
摘要:public class Solution { public int[] PlusOne(int[] digits) { var last = digits[digits.Length - 1]; if (last + 1 < 10) { digits[digits.Length - 1]++; r
阅读全文
posted @
2017-04-21 16:58
Sempron2800+
阅读(127)
推荐(0)
leetcode367
摘要:https://leetcode.com/problems/valid-perfect-square/#/description
阅读全文
posted @
2017-04-21 16:08
Sempron2800+
阅读(114)
推荐(0)
leetcode101
摘要:/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNod
阅读全文
posted @
2017-04-21 13:26
Sempron2800+
阅读(231)
推荐(0)
leetcode345
摘要:https://leetcode.com/problems/reverse-vowels-of-a-string/#/description
阅读全文
posted @
2017-04-21 10:06
Sempron2800+
阅读(119)
推荐(0)
leetcode27
摘要:public class Solution { public int RemoveElement(int[] nums, int val) { var len = nums.Length; var count = 0; for (int i = 0; i < nums.Length; i++) {
阅读全文
posted @
2017-04-21 09:53
Sempron2800+
阅读(106)
推荐(0)
leetcode342
摘要:https://leetcode.com/problems/power-of-four/#/description
阅读全文
posted @
2017-04-21 09:01
Sempron2800+
阅读(104)
推荐(0)
leetcode198
摘要:https://leetcode.com/problems/house-robber/#/description /* 你是一个专业强盗,并计划沿街去盗窃每一个住户。每个房子都有一定量的现金,阻止你盗窃的唯一阻碍是相邻的两个房子之间有安全系统。一旦这两个房子同时被盗窃,系统就会自动联系警察。给定一系
阅读全文
posted @
2017-04-20 16:09
Sempron2800+
阅读(203)
推荐(0)
leetcode501
摘要:https://leetcode.com/problems/find-mode-in-binary-search-tree/#/description
阅读全文
posted @
2017-04-20 15:31
Sempron2800+
阅读(176)
推荐(0)
leetcode235
摘要:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/#/description
阅读全文
posted @
2017-04-20 15:09
Sempron2800+
阅读(183)
推荐(0)
leetcode459
摘要:https://leetcode.com/problems/repeated-substring-pattern/#/description
阅读全文
posted @
2017-04-20 11:50
Sempron2800+
阅读(102)
推荐(0)
leetcode21
摘要:/** * Definition for singly-linked list. * public class ListNode { * public int val; * public ListNode next; * public ListNode(int x) { val = x; } * }
阅读全文
posted @
2017-04-20 11:17
Sempron2800+
阅读(181)
推荐(0)
leetcode263
摘要:public class Solution { private bool Judge(int x) { if (x <= 1) { return false; } int bound = Convert.ToInt32(Math.Sqrt(x)); for (int i = 2; i <= boun
阅读全文
posted @
2017-04-20 09:06
Sempron2800+
阅读(100)
推荐(0)
leetcode107
摘要:https://leetcode.com/problems/binary-tree-level-order-traversal-ii/#/description
阅读全文
posted @
2017-04-19 23:12
Sempron2800+
阅读(100)
推荐(0)
leetcode191
摘要:public class Solution { public int HammingWeight(uint n) { var list = new List<uint>(); do { var x = n % 2; list.Add(x); n = n / 2; } while (n != 0);
阅读全文
posted @
2017-04-19 21:59
Sempron2800+
阅读(115)
推荐(0)
leetcode7
摘要:public class Solution { public int Reverse(int x) { int fuhao = 1; if (x < 0) { fuhao = -1; } try { x = Math.Abs(x); } catch (Exception e) { return 0;
阅读全文
posted @
2017-04-19 11:53
Sempron2800+
阅读(203)
推荐(0)
leetcode1
摘要:方案一:算法思想:两层循环。时间负责度:O(n^2),空间复杂度O(1)。代码使用C#实现: 1 public class Solution 2 { 3 public int[] TwoSum(int[] nums, int target) 4 { 5 var ary = new int[2]; 6
阅读全文
posted @
2017-04-19 11:52
Sempron2800+
阅读(1400)
推荐(0)
leetcode53
摘要:https://leetcode.com/problems/maximum-subarray/#/description 补充一个python的实现: 算法思路:贪心法。
阅读全文
posted @
2017-04-19 11:47
Sempron2800+
阅读(211)
推荐(0)
leetcode70
摘要:public class Solution { public int ClimbStairs(int n) { //递归方法,效率低 //if (n <= 0) //{ // return 0; //} //else if (n == 1) //{ // return 1; //} //else i
阅读全文
posted @
2017-04-19 11:46
Sempron2800+
阅读(198)
推荐(0)
leetcode437
摘要:https://leetcode.com/problems/path-sum-iii/#/description 补充一个python实现,使用递归: 这种实现的时间复杂度是O(n^2),执行效率比较低。 再补充一个更高效的实现,使用hash表进行缓存:(如果必须符合这个时间复杂度的要求O(n),就
阅读全文
posted @
2017-04-19 11:44
Sempron2800+
阅读(147)
推荐(0)
leetcode35
摘要:public class Solution { public int SearchInsert(int[] nums, int target) { for (int i = 0; i < nums.Length; i++) { if (nums[i] >= target) { return i; }
阅读全文
posted @
2017-04-19 11:42
Sempron2800+
阅读(158)
推荐(0)
leetcode83
摘要:/** * Definition for singly-linked list. * public class ListNode { * public int val; * public ListNode next; * public ListNode(int x) { val = x; } * }
阅读全文
posted @
2017-04-19 11:40
Sempron2800+
阅读(168)
推荐(0)
leetcode231
摘要:public class Solution { public bool IsPowerOfTwo(int n) { return ((n & (n - 1)) == 0 && n > 0); } } https://leetcode.com/problems/power-of-two/#/descr
阅读全文
posted @
2017-04-19 11:39
Sempron2800+
阅读(140)
推荐(0)
leetcode326
摘要:https://leetcode.com/problems/power-of-three/#/description 使用循环实现,python
阅读全文
posted @
2017-04-19 11:38
Sempron2800+
阅读(160)
推荐(0)
leetcode202
摘要:https://leetcode.com/problems/happy-number/#/description 补充一个python的实现: 使用集合s记录已经出现过的数字: 如果出现数字1,则返回True; 如果在出现重复的数字之前都没有出现过1,则返回False。
阅读全文
posted @
2017-04-19 11:37
Sempron2800+
阅读(162)
推荐(0)
leetcode121
摘要:public class Solution { public int MaxProfit(int[] prices) { //寻找最优极值点(包括2个端点) if (prices.Length < 2) { return 0; } else if (prices.Length == 2) { ret
阅读全文
posted @
2017-04-19 11:36
Sempron2800+
阅读(188)
推荐(0)
leetcode405
摘要:https://leetcode.com/problems/convert-a-number-to-hexadecimal/#/description
阅读全文
posted @
2017-04-19 11:35
Sempron2800+
阅读(210)
推荐(0)
leetcode415
摘要:https://leetcode.com/problems/add-strings/#/description
阅读全文
posted @
2017-04-19 11:33
Sempron2800+
阅读(223)
推荐(0)
leetcode543
摘要:https://leetcode.com/problems/diameter-of-binary-tree/#/description 补充一种递归的方式,使用python实现: 思路是每次递归判断,以当前节点为根节点是否能达到最大,见第14行。 而每次递归向上返回的是当前节点的左右子树的高度的更大
阅读全文
posted @
2017-04-19 11:32
Sempron2800+
阅读(223)
推荐(0)
leetcode108
摘要:/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNod
阅读全文
posted @
2017-04-19 11:32
Sempron2800+
阅读(138)
推荐(0)
leetcode551
摘要:https://leetcode.com/problems/student-attendance-record-i/#/description
阅读全文
posted @
2017-04-19 11:30
Sempron2800+
阅读(171)
推荐(0)
leetcode541
摘要:https://leetcode.com/problems/reverse-string-ii/#/description
阅读全文
posted @
2017-04-19 11:29
Sempron2800+
阅读(176)
推荐(0)
leetcode447
摘要:https://leetcode.com/problems/number-of-boomerangs/#/description
阅读全文
posted @
2017-04-19 11:28
Sempron2800+
阅读(251)
推荐(0)
leetcode268
摘要:public class Solution { public int MissingNumber(int[] nums) { var list = nums.OrderBy(x => x).ToList(); var preNum = 0; foreach (var l in list) { if
阅读全文
posted @
2017-04-19 11:28
Sempron2800+
阅读(152)
推荐(0)
leetcode350
摘要:public class Solution { public int[] Intersect(int[] nums1, int[] nums2) { var len1 = nums1.Length; var len2 = nums2.Length; var list = new List<int>(
阅读全文
posted @
2017-04-19 11:27
Sempron2800+
阅读(132)
推荐(0)
leetcode206
摘要:https://leetcode.com/problems/reverse-linked-list/#/description 简化的代码: 补充一个python的实现:
阅读全文
posted @
2017-04-19 11:25
Sempron2800+
阅读(163)
推荐(0)
leetcode401
摘要:https://leetcode.com/problems/binary-watch/#/description
阅读全文
posted @
2017-04-19 11:24
Sempron2800+
阅读(201)
推荐(0)
leetcode13
摘要:public class Solution { private int ChangeToInt(char c) { var number = 0; string s = c.ToString(); switch (s) { case "I": number = 1; break; case "V":
阅读全文
posted @
2017-04-19 11:24
Sempron2800+
阅读(155)
推荐(0)
leetcode217
摘要:public class Solution { public bool ContainsDuplicate(int[] nums) { var list = nums.Distinct(); if (list.Count() == nums.Length) { return false; } els
阅读全文
posted @
2017-04-19 11:23
Sempron2800+
阅读(160)
推荐(0)
leetcode409
摘要:https://leetcode.com/problems/longest-palindrome/#/description
阅读全文
posted @
2017-04-19 11:22
Sempron2800+
阅读(116)
推荐(0)
leetcode504
摘要:https://leetcode.com/problems/base-7/#/description
阅读全文
posted @
2017-04-19 11:21
Sempron2800+
阅读(140)
推荐(0)
leetcode242
摘要:public class Solution { public bool IsAnagram(string s, string t) { Dictionary<char, int> dic = new Dictionary<char, int>(); foreach (var c in s) { if
阅读全文
posted @
2017-04-19 11:20
Sempron2800+
阅读(198)
推荐(0)
leetcode169
摘要:public class Solution { public int MajorityElement(int[] nums) { Dictionary<int, int> dic = new Dictionary<int, int>(); var len = nums.Length; for (in
阅读全文
posted @
2017-04-19 11:19
Sempron2800+
阅读(268)
推荐(0)
leetcode100
摘要:/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNod
阅读全文
posted @
2017-04-19 11:18
Sempron2800+
阅读(189)
推荐(0)
leetcode237
摘要:/** * Definition for singly-linked list. * public class ListNode { * public int val; * public ListNode next; * public ListNode(int x) { val = x; } * }
阅读全文
posted @
2017-04-19 11:17
Sempron2800+
阅读(142)
推荐(0)
leetcode171
摘要:https://leetcode.com/problems/excel-sheet-column-number/#/description 补充一个python的实现:
阅读全文
posted @
2017-04-19 11:16
Sempron2800+
阅读(228)
推荐(0)
leetcode122
摘要:public class Solution { public int MaxProfit(int[] prices) { var list = new List<KeyValuePair<int, int>>(); //记录所有的极大值和极小值 if (prices.Length <= 1) { r
阅读全文
posted @
2017-04-19 11:15
Sempron2800+
阅读(201)
推荐(0)
leetcode387
摘要:public class Solution { public int FirstUniqChar(string s) { Dictionary<char, int> dic = new Dictionary<char, int>(); foreach (char c in s) { if (!dic
阅读全文
posted @
2017-04-19 11:14
Sempron2800+
阅读(176)
推荐(0)
leetcode404
摘要:https://leetcode.com/problems/sum-of-left-leaves/#/description 补充一个python的实现:
阅读全文
posted @
2017-04-19 11:13
Sempron2800+
阅读(103)
推荐(0)
leetcode349
摘要:https://leetcode.com/problems/intersection-of-two-arrays/#/description
阅读全文
posted @
2017-04-19 11:12
Sempron2800+
阅读(88)
推荐(0)
leetcode383
摘要:https://leetcode.com/problems/ransom-note/#/description
阅读全文
posted @
2017-04-19 11:11
Sempron2800+
阅读(178)
推荐(0)
leetcode453
摘要:https://leetcode.com/problems/minimum-moves-to-equal-array-elements/#/description
阅读全文
posted @
2017-04-19 11:10
Sempron2800+
阅读(126)
推荐(0)
leetcode455
摘要:public class Solution { public int FindContentChildren(int[] g, int[] s) { var listg = g.OrderBy(x => x).ToList(); var lists = s.OrderBy(x => x).ToLis
阅读全文
posted @
2017-04-19 11:09
Sempron2800+
阅读(118)
推荐(0)
leetcode167
摘要:public class Solution { public int[] TwoSum(int[] numbers, int target) { Dictionary<int, int> dic = new Dictionary<int, int>(); int count = numbers.Co
阅读全文
posted @
2017-04-19 11:08
Sempron2800+
阅读(136)
推荐(0)
leetcode506
摘要:https://leetcode.com/problems/relative-ranks/#/description
阅读全文
posted @
2017-04-19 11:07
Sempron2800+
阅读(152)
推荐(0)
leetcode530
摘要:https://leetcode.com/problems/minimum-absolute-difference-in-bst/#/description
阅读全文
posted @
2017-04-19 11:06
Sempron2800+
阅读(128)
推荐(0)
leetcode283
摘要:public class Solution { public void MoveZeroes(int[] nums) { int index = 0; for (int i = 0; i < nums.Length; i++) { //[0, 1, 0, 3, 12] //[1, 3, 12, 0,
阅读全文
posted @
2017-04-19 11:06
Sempron2800+
阅读(151)
推荐(0)
leetcode521
摘要:https://leetcode.com/problems/longest-uncommon-subsequence-i/#/description
阅读全文
posted @
2017-04-19 11:04
Sempron2800+
阅读(131)
推荐(0)
leetcode492
摘要:https://leetcode.com/problems/construct-the-rectangle/#/description
阅读全文
posted @
2017-04-19 11:04
Sempron2800+
阅读(122)
推荐(0)
leetcode258
摘要:https://leetcode.com/problems/add-digits/#/description
阅读全文
posted @
2017-04-19 11:03
Sempron2800+
阅读(110)
推荐(0)
leetcode226
摘要:https://leetcode.com/problems/invert-binary-tree/#/description 补充一个使用层次遍历处理的方案,java实现 补充一个python的实现:
阅读全文
posted @
2017-04-19 11:02
Sempron2800+
阅读(143)
推荐(0)
leetcode371
摘要:public class Solution { public int GetSum(int a, int b) { return b == 0 ? a : GetSum(a ^ b, (a & b) << 1); } } https://leetcode.com/problems/sum-of-tw
阅读全文
posted @
2017-04-19 11:00
Sempron2800+
阅读(129)
推荐(0)
leetcode104
摘要:/** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNod
阅读全文
posted @
2017-04-19 10:59
Sempron2800+
阅读(128)
推荐(0)
leetcode389
摘要:https://leetcode.com/problems/find-the-difference/#/description
阅读全文
posted @
2017-04-19 10:59
Sempron2800+
阅读(124)
推荐(0)
leetcode448
摘要:https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/#/description
阅读全文
posted @
2017-04-19 10:58
Sempron2800+
阅读(141)
推荐(0)
leetcode520
摘要:https://leetcode.com/problems/detect-capital/#/description
阅读全文
posted @
2017-04-19 10:57
Sempron2800+
阅读(131)
推荐(0)
leetcode136
摘要:public class Solution { public int SingleNumber(int[] nums) { Dictionary<int, int> dic = new Dictionary<int, int>(); foreach (var n in nums) { if (!di
阅读全文
posted @
2017-04-19 10:56
Sempron2800+
阅读(235)
推荐(0)
leetcode292
摘要:https://leetcode.com/problems/nim-game/#/description
阅读全文
posted @
2017-04-19 10:55
Sempron2800+
阅读(112)
推荐(0)
leetcode485
摘要:https://leetcode.com/problems/max-consecutive-ones/#/description
阅读全文
posted @
2017-04-19 10:55
Sempron2800+
阅读(113)
推荐(0)
leetcode463
摘要:https://leetcode.com/problems/island-perimeter/#/description
阅读全文
posted @
2017-04-19 10:54
Sempron2800+
阅读(152)
推荐(0)
leetcode496
摘要:https://leetcode.com/problems/next-greater-element-i/#/description
阅读全文
posted @
2017-04-19 10:53
Sempron2800+
阅读(185)
推荐(0)
leetcode344
摘要:https://leetcode.com/problems/reverse-string/#/description 下面是使用C++的解决方案,不实用api: 这道题目有所变化,原来的要求是返回string,现在的要求是不返回任何值,而是在原来的字符串上直接修改。 下面使用python实现新的要求
阅读全文
posted @
2017-04-19 10:52
Sempron2800+
阅读(141)
推荐(0)
leetcode412
摘要:public class Solution { public IList<string> FizzBuzz(int n) { var list = new List<string>(); for (int i = 1; i <= n; i++) { if (i % 15 == 0) { list.A
阅读全文
posted @
2017-04-19 10:51
Sempron2800+
阅读(132)
推荐(0)
leetcode500
摘要:https://leetcode.com/problems/keyboard-row/#/description
阅读全文
posted @
2017-04-19 10:50
Sempron2800+
阅读(194)
推荐(0)
leetcode476
摘要:https://leetcode.com/problems/number-complement/#/description
阅读全文
posted @
2017-04-19 10:48
Sempron2800+
阅读(127)
推荐(0)
leetcode557
摘要:https://leetcode.com/problems/reverse-words-in-a-string-iii/#/description
阅读全文
posted @
2017-04-19 10:46
Sempron2800+
阅读(111)
推荐(0)
leetcode461
摘要:public class Solution { public int HammingDistance(int x, int y) { int[] aryA = new int[32]; int[] aryB = new int[32]; int i = 0; int j = 0; do { aryA
阅读全文
posted @
2017-04-19 10:45
Sempron2800+
阅读(137)
推荐(0)