LeetCode
LeetCode算法题的学习笔记。
微观尽头
求木之长者,必固其根本
展开
-
LeetCode--medium--interleaving_string_97
summary:divide and conquer | memorizationpackage myapp.kit.leetcode.top200;import java.util.HashMap;import java.util.Map;/** * * 97 * hard * https://leetcode.com/problems/interleaving-string/ * * Given s1, s2, s3, find whether s3 is formed原创 2020-07-22 19:45:11 · 275 阅读 · 0 评论 -
LeetCode--medium--valid_number_65
summary:DFApackage myapp.kit.leetcode.top200;import java.util.HashMap;import java.util.HashSet;import java.util.Map;import java.util.Set;/** * * 65 * hard * https://leetcode.com/problems/valid-number/ * * Validate if a given string can be原创 2020-07-22 19:43:32 · 264 阅读 · 0 评论 -
LeetCode--medium--search_in_rotated_array_ii_81
summary:binary searchpackage myapp.kit.leetcode.top200;/** * 81 * medium * https://leetcode.com/problems/search-in-rotated-sorted-array-ii/ * * Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. * *原创 2020-07-22 19:40:52 · 144 阅读 · 0 评论 -
LeetCode--medium--scramble_string_87
summary:divide and conquer | memorizationpackage myapp.kit.leetcode.top200;import java.util.HashMap;import java.util.Map;/** * 87 * hard *https://leetcode.com/problems/scramble-string/ * * Given a string s1, we may represent it as a binary原创 2020-07-22 19:39:53 · 121 阅读 · 0 评论 -
LeetCode--medium--rotate_list_61
summary:two pointerspackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * * 61 * medium * https://leetcode.com/problems/rotate-list/ * * Given a linked list, rotate the list to the right by k places, where k is non-原创 2020-07-22 19:37:47 · 131 阅读 · 0 评论 -
LeetCode--medium--remove_duplicates_from_sorted_list_83
summary:linked listpackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * 83 * easy *https://leetcode.com/problems/remove-duplicates-from-sorted-list/ * * Given a sorted linked list, delete all duplicates such that ea原创 2020-07-20 11:12:17 · 188 阅读 · 0 评论 -
LeetCode--medium--remove_duplicates_from_sorted_list_82
summary:linked listpackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * 82 * medium * https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ * * Given a sorted linked list, delete all nodes that have d原创 2020-07-20 11:11:20 · 97 阅读 · 0 评论 -
LeetCode--medium--remove_duplicates_from_sorted_array_ii_80
summary:arraypackage myapp.kit.leetcode.top200;/** * * * 80 * medium * https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/ * * Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most t原创 2020-07-20 11:10:31 · 189 阅读 · 0 评论 -
LeetCode--medium--permutation_sequence_60
/** * summary: * approach 1 : dfs backtrack but TLE ! * * approach 2 : math * candidate: [1,2,3,4,...n] kth * 1. calculate block size : (n - 1)! * 2. renew candidate and k * new k = k % (n - 1)! * .原创 2020-07-20 11:08:30 · 118 阅读 · 0 评论 -
LeetCode--medium--partition_list_86
summary:divide and conquer | two pointerspackage myapp.kit.leetcode.top200;import myapp.kit.leetcode.base.ListNode;/** * * 86 * medium * https://leetcode.com/problems/partition-list/ * * * Given a linked list and a value x, partition it suc原创 2020-07-20 11:05:57 · 97 阅读 · 0 评论 -
LeetCode--medium--n_queens_ii_52
summary:backtrackpackage myapp.kit.leetcode.top200;import java.util.ArrayList;import java.util.List;/** * * 52 * hard * https://leetcode.com/problems/n-queens-ii/ * * The n-queens puzzle is the problem of placing n queens on an n×n chessboa原创 2020-07-20 11:04:50 · 197 阅读 · 0 评论 -
LeetCode--medium--n_queens_51
summary:backtrackpackage myapp.kit.leetcode.top200;import java.util.ArrayList;import java.util.List;/** * * 51 * hard *https://leetcode.com/problems/n-queens/ * The n-queens puzzle is the problem of placing n queens on an n×n chessboard such原创 2020-07-20 11:03:50 · 109 阅读 · 0 评论 -
LeetCode--medium--multiply_strings_43
summary:handle carrypackage myapp.kit.leetcode.top200;/** * 43 * medium * https://leetcode.com/problems/multiply-strings/ * * Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, * also rep原创 2020-07-20 11:02:55 · 148 阅读 · 0 评论 -
LeetCode--medium--combinations_77
summary:combinations | backtrackpackage myapp.kit.leetcode.top200;import java.util.ArrayList;import java.util.List;/** * * 77 * medium * https://leetcode.com/problems/combinations/ * * Given two integers n and k, return all possible combina原创 2020-07-20 11:01:42 · 120 阅读 · 0 评论 -
LeetCode--medium--add_binary_67
summary:handle carrypackage myapp.kit.leetcode.top200;/** * * 67 * medium * https://leetcode.com/problems/add-binary/ * * Given two binary strings, return their sum (also a binary string). * * The input strings are both non-empty and contain原创 2020-07-20 11:00:31 · 92 阅读 · 0 评论 -
LeetCode--12--medium--IntegerToRoman
summary:classified discussionpackage myapp.kit.leetcode.top200;/** * 12 * medium * https://leetcode.com/problems/integer-to-roman/ * * Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. * * Symbol Value原创 2020-06-29 21:40:56 · 129 阅读 · 0 评论 -
LeetCode--6--medium--ZigZagConversion
summary:calculatepackage myapp.kit.leetcode.top200;/** * 6 * medium * https://leetcode.com/problems/zigzag-conversion/ * * The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display原创 2020-06-22 10:50:10 · 130 阅读 · 0 评论 -
LeetCode--127--medium--WordLadder
summary:bfspackage myapp.kit.leetcode.top145;import java.util.ArrayList;import java.util.HashSet;import java.util.List;import java.util.Set;/** * * 127 * medium * https://leetcode.com/problems/word-ladder/ * * * Given two words (beginWor原创 2020-06-22 10:48:35 · 98 阅读 · 0 评论 -
LeetCode--140--hard--WordBreakII
summary:memorizationpackage myapp.kit.leetcode.top145;import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.Map;import java.util.Set;/** * 140 * hard * https://leetcode.com/prob原创 2020-06-22 10:47:06 · 114 阅读 · 0 评论 -
LeetCode--44--hard--WildcardMatching
summary:memorization cache | dynamic programpackage myapp.kit.leetcode.top145;/** * * 44 * hard * https://leetcode.com/problems/wildcard-matching/ * * Given an input string (s) and a pattern (p), implement wildcard pattern matching with suppo原创 2020-06-21 20:28:30 · 152 阅读 · 0 评论 -
LeetCode--680--easy--ValidPalindromeII
summary:two pointerspackage myapp.kit.leetcode.top145;/** * * 680 * easy * https://leetcode.com/problems/valid-palindrome-ii/ * *Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. *原创 2020-06-21 20:15:58 · 135 阅读 · 0 评论 -
LeetCode--125--easy--ValidPalindrome
summary:two pointerspackage myapp.kit.leetcode.top145;/** * * 125 * easy *https://leetcode.com/problems/valid-palindrome/ * * * Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. *原创 2020-06-21 20:14:32 · 151 阅读 · 0 评论 -
LeetCode--37--hard--SudokuSolver
summary:dfs search | backtrackpackage myapp.kit.leetcode.top145;import java.util.HashSet;import java.util.Set;/** * * 37 * hard * https://leetcode.com/problems/sudoku-solver/ * * Write a program to solve a Sudoku puzzle by filling the empt.原创 2020-06-21 20:13:02 · 170 阅读 · 0 评论 -
LeetCode--73--medium--SetMatrixZeroes
summary:hash tablepackage myapp.kit.leetcode.top145;import java.util.HashSet;import java.util.Set;/** * * 73 * medium * https://leetcode.com/problems/set-matrix-zeroes/ * * Given a m x n matrix, if an element is 0, set its entire row and co原创 2020-06-21 20:11:10 · 152 阅读 · 0 评论 -
LeetCode--50--medium--Pow
summary:divide and conquerpackage myapp.kit.leetcode.top145;/** * * 50 * medium * https://leetcode.com/problems/powx-n/ * * Implement pow(x, n), which calculates x raised to the power n (xn). * * Example 1: * * Input: 2.00000, 10 * Output原创 2020-06-21 20:10:17 · 124 阅读 · 0 评论 -
LeetCode--131--medium--PalindromePartitioning
summary:dfs search | memorization cachepackage myapp.kit.leetcode.top145;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;/** * * 131 * medium * https://leetcode.com/problems/palindrome-partitio原创 2020-06-21 20:08:52 · 104 阅读 · 0 评论 -
LeetCode--134--medium--GasStation
summary:dfs search | greedy (todo)package myapp.kit.leetcode.top145;/** * * 134 * medium * https://leetcode.com/problems/gas-station/ * * There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. * * Yo原创 2020-06-21 20:07:16 · 100 阅读 · 0 评论 -
LeetCode--91--medium--DecodeWays
summary:dynamic programpackage myapp.kit.leetcode.top145;import java.util.HashMap;import java.util.Map;/** * * 91 * medium *https://leetcode.com/problems/decode-ways/ * * A message containing letters from A-Z is being encoded to numbers usi原创 2020-06-21 20:05:01 · 1289 阅读 · 0 评论 -
LeetCode--224--hard--BasicCalculator
summary:stack | infix expression - > prefixpackage myapp.kit.leetcode.top145;import java.util.Stack;/** * * 224 * hard * https://leetcode.com/problems/basic-calculator/ * * Implement a basic calculator to evaluate a simple expression str.原创 2020-06-21 20:02:59 · 130 阅读 · 0 评论 -
LeetCode--36--medium--ValidSudoku
summary:step by steppackage myapp.kit.leetcode.top145;import java.util.HashSet;import java.util.Set;/** * * 36 * medium * https://leetcode.com/problems/valid-sudoku/ * * Determine if a 9x9 Sudoku board is valid. Only the filled cells need t原创 2020-06-07 23:20:21 · 116 阅读 · 0 评论 -
LeetCode--38--medium--CountAndSay
summary:hash tablepackage myapp.kit.leetcode.top145;/** * * 38 * easy * https://leetcode.com/problems/count-and-say/ * * The count-and-say sequence is the sequence of integers with the first five terms as following: * * 1. 1 * 2. 11原创 2020-06-07 23:17:33 · 133 阅读 · 0 评论 -
LeetCode--8--medium--StringToInteger
summary:a lot of border casepackage myapp.kit.leetcode.top145;/** * 8 * medium * https://leetcode.com/problems/string-to-integer-atoi/ * * Implement atoi which converts a string to an integer. * * The function first discards as many whitespac原创 2020-06-07 23:15:41 · 119 阅读 · 0 评论 -
LeetCode--560--medium--SubarraySumEqualsK
summary:hash table | mathpackage myapp.kit.leetcode.top100liked;import java.util.HashMap;import java.util.Map;/** * *560 * medium * https://leetcode.com/problems/subarray-sum-equals-k/ * * * * Given an array of integers and an integer k,原创 2020-06-02 20:29:01 · 124 阅读 · 0 评论 -
LeetCode--494--medium--TargetSum
summary:divide and conquer | pruningpackage myapp.kit.leetcode.top100liked;import java.util.Arrays;/** * * 494 * medium * https://leetcode.com/problems/target-sum/ * * You are given a list of non-negative integers, a1, a2, ..., an, and a tar原创 2020-06-02 20:28:14 · 115 阅读 · 0 评论 -
LeetCode--438--medium--FindAllAnagramsInAString
summary:sliding windowpackage myapp.kit.leetcode.top100liked;import java.util.ArrayList;import java.util.Arrays;import java.util.HashSet;import java.util.List;import java.util.Set;/** * * 438 * medium * https://leetcode.com/problems/find-.原创 2020-05-28 20:33:08 · 139 阅读 · 0 评论 -
LeetCode--416--medium--PartitionEqualSubsetSum
summary:dynamic program | 0-1 knapsack programpackage myapp.kit.leetcode.top100liked;/** * * 416 * medium * https://leetcode.com/problems/partition-equal-subset-sum/ * * Given a non-empty array containing only positive integers, find if the a原创 2020-05-28 00:56:04 · 84 阅读 · 0 评论 -
LeetCode--301--hard--RemoveInvalidParentheses
summary:divide and conquer | state transitionpackage myapp.kit.leetcode.top100liked;import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.Map;import java.util.Set;/** * 301 * har原创 2020-05-28 00:53:59 · 112 阅读 · 0 评论 -
LeetCode--394--medium--DecodeString
summary:stack | case by casepackage myapp.kit.leetcode.top100liked;import java.util.Stack;/** * 394 * medium * https://leetcode.com/problems/decode-string/ * * * Given an encoded string, return its decoded string. * * The encoding rule is:原创 2020-05-28 00:50:22 · 95 阅读 · 0 评论 -
LeetCode--312--hard--BurstBalloons
summary:dynamic program | interval dppackage myapp.kit.leetcode.top100liked;/** * * 312 * hard * https://leetcode.com/problems/burst-balloons/ * * Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represente原创 2020-05-28 00:48:30 · 96 阅读 · 0 评论 -
LeetCode--297--hard--SerializeAndDeserializeBinaryTree
summary:level order | BFS | queuepackage myapp.kit.leetcode.top100liked;import myapp.kit.leetcode.base.TreeNode;import java.util.LinkedList;import java.util.Queue;/** * * 297 * hard * https://leetcode.com/problems/serialize-and-deserialize-原创 2020-05-20 00:50:55 · 115 阅读 · 0 评论