摘要:
题目链接 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)