Valid Parentheses
LeetCode https://leetcode.cn/problems/valid-parentheses/ class Solution { public boolean isValid(String s) { if (s.length() < 2) { return false; } Stack&...
LeetCode https://leetcode.cn/problems/valid-parentheses/ class Solution { public boolean isValid(String s) { if (s.length() < 2) { return false; } Stack&...
LeetCode https://leetcode.cn/problems/rotate-array/ class Solution { public void rotate(int[] nums, int k) { // index 0 1 2 3 4 5 6 // nums 1 2 3 4 5 6 7 ...
LeetCode https://leetcode.cn/problems/merge-intervals/ class Solution { public int[][] merge(int[][] intervals) { if (intervals == null || intervals.length < 1) { return...
LeetCode https://leetcode.cn/problems/maximum-subarray/ class Solution { public int maxSubArray(int[] nums) { if (nums == null || nums.length < 1) { return 0; } ...
LeetCode https://leetcode.cn/problems/minimum-window-substring/ Description Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity ...
LeetCode https://leetcode.cn/problems/sliding-window-maximum/ class Solution { public int[] maxSlidingWindow(int[] nums, int k) { if (nums == null || nums.length < 1 || k < 0 || ...
LeetCode https://leetcode.cn/problems/subarray-sum-equals-k/ class Solution { public int subarraySum(int[] nums, int k) { if (nums == null || nums.length < 1) { return 0...
LeetCode https://leetcode.cn/problems/trapping-rain-water/ DP Method class Solution { public int trap(int[] height) { int len = height.length; int[] leftMax = new int[len]; ...
LeetCode https://leetcode.cn/problems/find-all-anagrams-in-a-string/ class Solution { public List<Integer> findAnagrams(String s, String p) { List<Integer> res = new ArrayL...
LeetCode https://leetcode.cn/problems/3sum/ class Solution { public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> results = new ArrayList<&g...