摘要: My solution: class Solution { public boolean isMonotonic(int[] nums) { if(nums==null||nums.length<3){ return true; } int first = nums[0]; int second = 阅读全文
posted @ 2022-04-21 01:33 阳光明媚的菲越 阅读(12) 评论(0) 推荐(0) 编辑
摘要: class Solution { public String removeDuplicateLetters(String s) { int[] lastIndex = new int[26]; for (int i = 0; i < s.length(); i++){ lastIndex[s.cha 阅读全文
posted @ 2022-04-20 13:54 阳光明媚的菲越 阅读(19) 评论(0) 推荐(0) 编辑
摘要: This is the similar problem with: https://www.cnblogs.com/feiflytech/p/16169025.html class Solution { public int[] dailyTemperatures(int[] t) { int[] 阅读全文
posted @ 2022-04-20 13:43 阳光明媚的菲越 阅读(15) 评论(0) 推荐(0) 编辑
摘要: This problem is as same as https://www.cnblogs.com/feiflytech/p/16169025.html class Solution { public int[] nextLargerNodes(ListNode head) { List<Inte 阅读全文
posted @ 2022-04-20 13:24 阳光明媚的菲越 阅读(14) 评论(0) 推荐(0) 编辑
摘要: This is a similiar problem with https://www.cnblogs.com/feiflytech/p/15862432.html The only differences are: 1. If no larger number can be returned, t 阅读全文
posted @ 2022-04-20 12:52 阳光明媚的菲越 阅读(18) 评论(0) 推荐(0) 编辑
摘要: This is the similiar problem with: https://www.cnblogs.com/feiflytech/p/16168587.html and https://www.cnblogs.com/feiflytech/p/16169025.html class Sol 阅读全文
posted @ 2022-04-20 11:59 阳光明媚的菲越 阅读(11) 评论(0) 推荐(0) 编辑
摘要: Using stack, two pass: class Solution { public int[] nextGreaterElements(int[] nums) { Stack<Integer> stk = new Stack<>(); int[] res = new int[nums.le 阅读全文
posted @ 2022-04-20 11:11 阳光明媚的菲越 阅读(13) 评论(0) 推荐(0) 编辑
摘要: My solution, time complexity O(m*n): class Solution { public int[] nextGreaterElement(int[] nums1, int[] nums2) { Map<Integer, Integer> map = new Hash 阅读全文
posted @ 2022-04-20 09:52 阳光明媚的菲越 阅读(21) 评论(0) 推荐(0) 编辑
摘要: My binary search solution: class Solution { public int[] searchRange(int[] nums, int target) { if(nums==null || nums.length==0) return new int[]{-1,-1 阅读全文
posted @ 2022-04-20 07:25 阳光明媚的菲越 阅读(12) 评论(0) 推荐(0) 编辑
摘要: My back tracking solution: class Solution { List<String> res = new ArrayList<>(); public List<String> generateParenthesis(int n) { backTracking(n, 0 , 阅读全文
posted @ 2022-04-19 11:23 阳光明媚的菲越 阅读(18) 评论(0) 推荐(0) 编辑