文章分类 -  LeetCode

3,无重复字符的最长子串
摘要:给定一个字符串,请你找出其中不含有重复字符的最长子串的长度。 思路:滑动窗口。建立一个动态的窗口(实际就是无重复的子串)遍历主串,每遍历一个新字符则在窗口中查找是否包含该字符,没有的话则窗口增大,继续遍历。若已存在该字符则记录窗口长度,将窗口滑动至重复字符后,继续向下遍历,最后返回窗口的最大长度。 阅读全文
posted @ 2021-05-26 15:11 会飞的金鱼 阅读(49) 评论(0) 推荐(0)
2,两数相加
摘要:给你两个非空的链表,表示两个非负的整数。它们每位数字都是按照逆序的方式存储的,并且每个节点只能存储一位数字。 请你将两个数组相加,并以相同形式返回一个表示和的链表。 你可以假设除了数字0之外,这两个数组都不会以0开头。 思路:就是两数相加,每个位置上的数字对应相加,还要考虑进位的情况。另外一个链表的 阅读全文
posted @ 2021-05-26 14:36 会飞的金鱼 阅读(46) 评论(0) 推荐(0)
1,两数之和
摘要:给定一个整数数组nums和一个整数目标值target,请你在该数组中找出和为目标值target的两个整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 思路:设置一个map存放未匹配上的元素值和下标,遍历数组,如 阅读全文
posted @ 2021-05-26 14:31 会飞的金鱼 阅读(34) 评论(0) 推荐(0)
4.Median of Two Sorted Arrays
摘要:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文
posted @ 2020-02-12 20:58 会飞的金鱼 阅读(109) 评论(0) 推荐(0)
3.Longest Substring Without Repeating Characters
摘要:Given a string,find the length of the longest substring without repeating characters. Appoach 1:Brute Force public int lengthOfLongestSubstring(String 阅读全文
posted @ 2020-02-12 12:45 会飞的金鱼 阅读(77) 评论(0) 推荐(0)
2.Add Two Numbers
摘要:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contai 阅读全文
posted @ 2020-02-05 16:13 会飞的金鱼 阅读(67) 评论(0) 推荐(0)
1.Two Sum
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2020-02-05 12:21 会飞的金鱼 阅读(122) 评论(0) 推荐(0)