双指针
泰勒乐了
这个作者很懒,什么都没留下…
展开
-
LeetCode345——字符串专题/双指针专题(5)反转字符串中的元音字母
反转字符串中的元音字母 编写一个函数,以字符串作为输入,反转该字符串中的元音字母。 示例 1: 输入:“hello” 输出:“holle” 示例 2: 输入:“leetcode” 输出:“leotcede” 元音字母:AEIOU (1)方法1:双指针+HashSet的contains方法 class Solution { public static String reverseVowels(String s){ HashSet set = new HashSet();原创 2020-10-22 14:20:26 · 138 阅读 · 0 评论 -
LeetCode15——三数之和(双指针)
15.三数之和 给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有满足条件且不重复的三元组。 注意:答案中不可以包含重复的三元组 public class Test { /** * 双指针 * @param nums * @return */ public static List<List<Integer>> threeSum(int[原创 2020-10-22 13:07:42 · 63 阅读 · 0 评论 -
LeetCode1——两数之和(暴力法,哈希表,双指针)
1. 两数之和 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 (1)暴力法 public class Test { /** * 暴力法 */ public static int[] twoSum(int[] nums, int target){ int n = nums.length;原创 2020-10-22 13:07:22 · 125 阅读 · 0 评论