leedCode
tutouxiaocaiji
这个作者很懒,什么都没留下…
展开
-
LeedCode15 三数之和
给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有和为 0 且不重复的三元组。 注意:答案中不可以包含重复的三元组。 public class Soulution { public List<List<Integer>> threeSum(int[] nums) { //难点在于去重,去重可以使用排序来解决 List<List<Integer转载 2021-09-27 19:39:26 · 41 阅读 · 0 评论 -
leedCode11. 盛最多水的容器
给你 n 个非负整数 a1,a2,…,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0) 。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 说明:你不能倾斜容器。 public class Solution { public int maxArea(int[] height) { //int a=0; int area=0; int temp转载 2021-09-25 19:25:17 · 44 阅读 · 0 评论 -
LeetCode10. 正则表达式匹配
给你一个字符串 s 和一个字符规律 p,请你来实现一个支持 ‘.’ 和 ‘’ 的正则表达式匹配。 ‘.’ 匹配任意单个字符 '’ 匹配零个或多个前面的那一个元素 所谓匹配,是要涵盖 整个 字符串 s的,而不是部分字符串。 public boolean isMatch(String s, String p) { int len1=s.length(); int len2=p.length(); boolean[][] dp=new boolean[len转载 2021-09-24 17:51:42 · 59 阅读 · 0 评论 -
leedCode 4寻找两个正序数组的中位数
给定两个大小分别为 m 和 n 的正序(从小到大)数组 nums1 和 nums2。请你找出并返回这两个正序数组的 中位数 。 class Solution { public double findMedianSortedArrays(int[] nums1, int[] nums2) { // int medium = 0; // ArrayList<Integer> arrayList=new ArrayList<>(); //转载 2021-09-22 18:55:47 · 59 阅读 · 0 评论 -
leetCode3.无重复字符的最长子串
描述:给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度。 class Solution { public int lengthOfLongestSubstring(String s) { String s1 = new String(); s1 = s; int res = 0; HashSet<Character> hashSet = new HashSet<>() for转载 2021-09-21 10:57:03 · 42 阅读 · 0 评论