leetcode
文章平均质量分 87
zxwtry
github: https://github.com/zxwtry weibo: www.weibo.com/zxwtry
展开
-
LeetCode011 Container With Most Water
详细见:leetcode.com/problems/container-with-most-water/Java Solution: githubpackage leetcode;public class P011_ContainerWithMostWater { /** * @author zxwtry * @email zxwtr原创 2017-03-28 17:21:50 · 287 阅读 · 0 评论 -
LeetCode014 Longest Common Prefix
详细见:leetcode.com/problems/longest-common-prefix/Java Solution: githubpackage leetcode;public class P014_LongestCommonPrefix { public static void main(String[] args) { } /* * 2 ms *原创 2017-03-28 17:27:43 · 232 阅读 · 0 评论 -
LeetCode015 3Sum
详细见:leetcode.com/problems/3sumJava Solution: githubpackage leetcode;import java.util.Arrays;import java.util.LinkedList;import java.util.List;public class P015_3SumEquals0 { public st原创 2017-03-28 17:28:42 · 241 阅读 · 0 评论 -
LeetCode40 Combination Sum II 解析
详细见:leetcode.com/problems/combination-sum-iiC和Python的去重算法,应该记住。Java是很久之前写的,并不好。规则是:相同数字。 1,前面选了,后面一定要选。 2,前面没选,后面可选可不选。注意一定要选到最后一位,才能判断。Java Solution: githubp原创 2017-04-06 22:20:53 · 373 阅读 · 0 评论 -
LeetCode041 First Missing Positive 解析
详细见:leetcode.com/problems/first-missing-positiveJava所用的算法不够清晰,见C和Python的while循环while的作用:将val的值放置到val-1的位置上Java Solution: githubpackage leetcode;public class P041_FirstMissingPositi原创 2017-04-06 22:21:50 · 247 阅读 · 0 评论 -
LeetCode039 Combination Sum
详细见:leetcode.com/problems/combination-sumJava Solution: githubpackage leetcode;import java.util.Arrays;import java.util.LinkedList;import java.util.List;public class P039_Combination_S原创 2017-04-05 15:47:22 · 246 阅读 · 0 评论 -
LeetCode042 Trapping Rain Water
详细见:leetcode.com/problems/trapping-rain-water很经典Java Solution: githubpackage leetcode;/* * 最大积水问题 */public class P042_TrappingRainWater { public static void main(String[] args)原创 2017-04-06 22:22:51 · 305 阅读 · 0 评论 -
LeetCode016 3Sum Closest
详细见:leetcode.com/problems/3sum-closestJava Solution: githubpackage leetcode;import java.util.Arrays;public class P016_3SumClosest { public static void main(String[] args) {// System.o原创 2017-03-29 15:52:00 · 234 阅读 · 0 评论 -
LeetCode017 Letter Combinations of a Phone Number
详细见:leetcode.com/problems/letter-combinations-of-a-phone-number/Java Solution: githubpackage leetcode;import java.util.LinkedList;import java.util.List;/* * Given a digit string, retur原创 2017-03-29 15:56:00 · 233 阅读 · 0 评论 -
LeetCode018 4Sum
详细见:leetcode.com/problems/4sum/Java Solution: githubpackage leetcode;import java.util.Arrays;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.uti原创 2017-03-29 15:59:44 · 215 阅读 · 0 评论 -
LeetCode43 Multiply Strings
详细见:leetcode.com/problems/multiply-stringsJava Solution: githubpackage leetcode;public class P043_MultiplyStrings { public static void main(String[] args) {// System.out.println(new Sol原创 2017-04-07 21:35:58 · 255 阅读 · 0 评论 -
LeetCode044 Wildcard Matching
详细见:leetcode.com/problems/wildcard-matchingJava Solution: githubpackage leetcode;public class P044_WildcardMatching { /* * 35 ms * 54.88% */ static class Solution4 { public bo原创 2017-04-07 21:36:10 · 226 阅读 · 0 评论 -
LeetCode045 Jump Game II
详细见:leetcode.com/problems/jump-game-iiJava Solution: githubpackage leetcode;/* 大致意思是: 从0开始跳,每次跳的步数 <= 当前的值 结果就是要跳到最后一个 求跳最少次数 */public class P045_JumpGameII { /* * 4 ms *原创 2017-04-07 21:36:27 · 217 阅读 · 0 评论 -
LeetCode46 Permutations
详细见:leetcode.com/problems/permutationsJava Solution: githubpackage leetcode;import java.util.Arrays;import java.util.LinkedList;import java.util.List;public class P046_Permutations {原创 2017-04-08 18:36:01 · 195 阅读 · 0 评论 -
LeetCode047 Permutations II
详细见:leetcode.com/problems/permutations-iiJava Solution: githubpackage leetcode;import java.util.LinkedList;import java.util.List;public class P047_PermutationsII { /* * 先用HashSet试原创 2017-04-08 18:36:32 · 211 阅读 · 0 评论 -
LeetCode048 Rotate Image
详细见:leetcode.com/problems/rotate-imageJava Solution: githubpackage leetcode;public class P048_RotateImage { /* * 0 ms * 26.00% */ static class Solution1 { public void rotate原创 2017-04-08 18:36:57 · 217 阅读 · 0 评论 -
LeetCode019 Remove Nth Node From End of List
详细见:leetcode.com/problems/remove-nth-node-from-end-of-listJava Solution: githubpackage leetcode;public class P019_RemoveNthFromEndOfList { /* * 1ms * 5.49% */ static class Solu原创 2017-03-30 11:13:00 · 219 阅读 · 0 评论 -
LeetCode020 Valid Parentheses
详细见:leetcode.com/problems/valid-parenthesesJava Solution: githubpackage leetcode;public class P020_ValidParentheses { public static void main(String[] args) {// System.out.println(new原创 2017-03-30 11:17:02 · 249 阅读 · 0 评论 -
LeetCode021 Merge Two Sorted Lists
详细见:leetcode.com/problems/merge-two-sorted-listsJava Solution: githubpackage leetcode;import tools.ListNode辅助.ListNode;public class P021_MergeTwoSortedLists { // 注意,最好不要新建ListNode /*原创 2017-03-30 11:21:13 · 255 阅读 · 0 评论 -
LeetCode49 Group Anagrams
详细见:leetcode.com/problems/anagramsJava Solution: githubpackage leetcode;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.LinkedList;import j原创 2017-04-09 16:34:17 · 217 阅读 · 0 评论 -
LeetCode050 Pow(x, n)
详细见:leetcode.com/problems/powx-nJava Solution: githubpackage leetcode;public class P050_PowXN { /* * 1 ms * 37.87% */ static class Solution1 { public double myPow(double x,原创 2017-04-09 16:34:40 · 347 阅读 · 0 评论 -
LeetCode051 N-Queens
详细见:leetcode.com/problems/n-queensJava Solution: githubpackage leetcode;import java.util.LinkedList;import java.util.List;public class P051_NQueens { public static void main(String[] a原创 2017-04-09 16:35:05 · 276 阅读 · 0 评论 -
LeetCode022 Generate Parentheses
详细见:leetcode.com/problems/generate-parentheses/Java Solution: githubpackage leetcode;import java.util.HashSet;import java.util.LinkedList;import java.util.List;public class P022_Genera原创 2017-03-31 21:11:59 · 231 阅读 · 0 评论 -
LeetCode023 Merge k Sorted Lists
详细见:leetcode.com/problems/merge-k-sorted-lists/解析:两两合并(Java),堆排序(C和Python)Java Solution: githubpackage leetcode;public class P023_MergeKSortedLists { /* * 1 2方法太垃圾了, * 改用两次合并法原创 2017-03-31 22:03:17 · 278 阅读 · 0 评论 -
LeetCode024 Swap Nodes in Pairs
详细见:leetcode.com/problems/swap-nodes-in-pairs/Java Solution: githubpackage leetcode;import tools.ListNode辅助.ListNode;public class P024_SwapNodesInPairs { public static void main(String原创 2017-03-31 22:10:25 · 202 阅读 · 0 评论 -
LeetCode002 Add Two Numbers
详细见:leetcode.com/problems/add-two-numbers/说明:链表操作+进位Java Solution: githubpackage leetcode;/*You are given two linked lists representing two non-negative numbers. The digits are stored in reverse ...原创 2017-03-25 08:58:16 · 486 阅读 · 0 评论 -
LeetCode025 Reverse Nodes in k-Group
详细见:leetcode.com/problems/reverse-nodes-in-k-groupJava Solution: githubpackage leetcode;/* * 25. Reverse Nodes in k-Group QuestionEditorial Solution My Submissions Total Accepted: 67154 T原创 2017-04-01 12:00:38 · 235 阅读 · 0 评论 -
LeetCode026 Remove Duplicates from Sorted Array
详细见:leetcode.com/problems/remove-duplicates-from-sorted-array/Java Solution: githubpackage leetcode;public class P026_RemoveDuplicatesFromSortedArray { public static void main(String[] args)原创 2017-04-01 12:04:09 · 202 阅读 · 0 评论 -
LeetCode027 Remove Element
详细见:leetcode.com/problems/remove-element/Java Solution: githubpackage leetcode;public class P027_RemoveElement { public static void main(String[] args) { int[] nums = {1, 2, 3, 4, 3, 2, 1,原创 2017-04-01 12:08:13 · 228 阅读 · 0 评论 -
LeetCode52 N-Queens II
详细见:leetcode.com/problems/n-queens-iiJava Solution: githubpackage leetcode;public class P052_NQueensII { public static void main(String[] args) { System.out.println(new Solution1().tota原创 2017-04-10 22:09:59 · 299 阅读 · 0 评论 -
LeetCode053 Maximum Subarray
详细见:leetcode.com/problems/maximum-subarrayJava Solution: githubpackage leetcode;public class P053_MaximumSubarray { public static void main(String[] args) { System.out.println(new Solut原创 2017-04-10 22:10:29 · 203 阅读 · 0 评论 -
LeetCode054 Spiral Matrix
详细见:leetcode.com/problems/spiral-matrixJava Solution: githubpackage leetcode;import java.util.LinkedList;import java.util.List;public class P054_SpiralMatrix { public static void main(原创 2017-04-10 22:10:55 · 341 阅读 · 0 评论 -
LeetCode003 Longest Substring Without Repeating Characters
详细见:leetcode.com/problems/longest-substring-without-repeating-characters/说明:map/dict/数组Java Solution: githubpackage leetcode;import java.util.Arrays;public class P003_LongestSub原创 2017-03-25 21:01:08 · 234 阅读 · 0 评论 -
LeetCode004 Median of Two Sorted Arrays
详细见:leetcode.com/problems/median-of-two-sorted-arrays/haracters/说明: 同时找两个,情况太多。精简成找一个就好了。Java Solution: githubpackage leetcode;/*There are two sorted arrays nums1 and nums2 of原创 2017-03-25 21:53:00 · 306 阅读 · 0 评论 -
LeetCode028 Implement strStr()
详细见:leetcode.com/problems/implement-strstrJava Solution: githubpackage leetcode;public class P028_ImplementStrStr { //AC 13ms 34.88% static class Solution { public int strStr(String原创 2017-04-02 13:11:04 · 198 阅读 · 0 评论 -
LeetCode029 Divide Two Integers
详细见:leetcode.com/problems/divide-two-integersJava Solution: githubpackage leetcode;public class P029_DivideTwoIntegers { /* * 这个方法会TLE */ static class Solution1 { public int div原创 2017-04-02 13:11:34 · 223 阅读 · 0 评论 -
LeetCode030 Substring with Concatenation of All Words
详细见:leetcode.com/problems/substring-with-concatenation-of-all-wordsJava Solution: githubpackage leetcode;import java.util.Arrays;import java.util.HashMap;import java.util.LinkedList;imp原创 2017-04-02 13:11:57 · 214 阅读 · 0 评论 -
LeetCode005 Longest Palindromic Substring
详细见:leetcode.com/problems/longest-palindromic-substring/说明: manacherJava Solution: githubpackage leetcode;/* * 假定存在唯一一个最长子序列 */public class P005_LongestPalindromicSubstring { public sta原创 2017-03-26 20:17:09 · 197 阅读 · 0 评论 -
LeetCode006 ZigZag Conversion
详细见: leetcode.com/problems/zigzag-conversion/Java Solution: githubpackage leetcode;import java.util.Arrays;/*6. ZigZag Conversion QuestionEditorial Solution My SubmissionsTotal Accep原创 2017-03-26 20:24:35 · 258 阅读 · 0 评论 -
LeetCode007 Reverse Integer
详细见:leetcode.com/problems/reverse-integer/Java Solution: githubpackage leetcode;/* * 7. Reverse Integer QuestionEditorial Solution My SubmissionsTotal Accepted: 156921Total Submissions:原创 2017-03-26 20:29:22 · 282 阅读 · 0 评论