随笔分类 - Leetcode
摘要:题目地址:https://leetcode-cn.com/problems/median-of-two-sorted-arrays/ 难度:困难 基本思路: 将两个有序链表合并,然后根据中位数定义查找 分段折半查找 合并链表(low的一笔) public class Solution { publi
阅读全文
摘要:题目地址:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ 难度:中等 基本思路: 首先区分子串和子序列,子串是连续的子序列,子序列相当于子集,可以是离散的 使用 sliding wind
阅读全文
摘要:题目地址:https://leetcode-cn.com/problems/add-two-numbers/ 难度:简单 基本思路: 大于10要考虑进位,具体进几位用整除,当前结点大小用模除 要考虑两条链表不一样长度的情况,所以遍历的判断条件是有一个不为空则继续,二者皆空则停止 class Solu
阅读全文
摘要:题目地址:https://leetcode-cn.com/problems/two-sum/ 难度:简单 基本思路: 暴力解法,通过两次遍历,查找和为目标数的两个数,并返回下标数组 使用哈希,一次遍历得到结果 class Solution { // 暴力解法 public int[] twoSum(
阅读全文