上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
摘要: 题目链接 class Solution { public boolean isValid(String s) { //初始化一个栈 Stack<Character> stack = new Stack<Character>(); //利用栈的先进后出的特性去检验括号能不能配对 for(char c 阅读全文
posted @ 2022-02-05 22:54 蹇爱黄 阅读(32) 评论(0) 推荐(0)
摘要: 题目链接 class Solution { public int threeSumClosest(int[] nums, int target) { int res = Integer.MAX_VALUE; Arrays.sort(nums); int sum = 0; for(int i = 0; 阅读全文
posted @ 2022-02-05 22:13 蹇爱黄 阅读(35) 评论(0) 推荐(0)
摘要: 题目链接 刚开始感觉哇这代码好长,还总写漏,但是写了几遍后感觉好了很多 class Solution { public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> result = new ArrayList<>(); 阅读全文
posted @ 2022-02-05 21:18 蹇爱黄 阅读(29) 评论(0) 推荐(0)
摘要: 题目链接 string.startsWith(s):一个字符串是不是以s开始 0ms class Solution { public String longestCommonPrefix(String[] strs) { if(strs == null || strs.length == 0) re 阅读全文
posted @ 2022-02-05 20:50 蹇爱黄 阅读(21) 评论(0) 推荐(0)
摘要: 题目链接 左右指针,不知道为什么挺慢的4ms public class Solution { public int maxArea(int[] height) { //定义左右指针 int l = 0,r = height.length-1; int ans = 0; while(l<r){ //找 阅读全文
posted @ 2022-02-05 11:52 蹇爱黄 阅读(21) 评论(0) 推荐(0)
摘要: 题目链接 easy题,没有奇奇怪怪的条件限制 class Solution{ public boolean isPalindrome(int x){ if(x<0) return false; //if(x<10) return true; int num = x; int ans = 0; whi 阅读全文
posted @ 2022-02-05 11:19 蹇爱黄 阅读(22) 评论(0) 推荐(0)
摘要: 题目链接 1.去除前导空格 2.第一个字符是数字吗 3.第一个字符是'+'吗 4.第一个字符是'-'吗 5.后边的每个字符是数字吗 class Solution { public int myAtoi(String s) { char[] chars = s.toCharArray(); int n 阅读全文
posted @ 2022-02-05 00:34 蹇爱黄 阅读(25) 评论(0) 推荐(0)
摘要: 题目链接 符合题意的解 class Solution { public int reverse(int x) { int ans = 0; while (x != 0) { int pop = x % 10; if (ans > Integer.MAX_VALUE / 10 || (ans == I 阅读全文
posted @ 2022-02-05 00:02 蹇爱黄 阅读(26) 评论(0) 推荐(0)
摘要: 题目链接 大佬的解题思路(身为菜狗的我压根没想这么多) class Solution { public double findMedianSortedArrays(int[] nums1, int[] nums2) { int m = nums1.length; int n = nums2.leng 阅读全文
posted @ 2022-02-04 23:08 蹇爱黄 阅读(21) 评论(0) 推荐(0)
摘要: 题目链接 2ms 中心扩散:每遍历一个元素就左右扩展 class Solution { public String longestPalindrome(String s) { if(s==null || s.length()==0) return ""; //保存起止位置 int[] range = 阅读全文
posted @ 2022-02-04 22:24 蹇爱黄 阅读(20) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页