# LeetCode **Repository Path**: kang-weichen/LeetCode ## Basic Information - **Project Name**: LeetCode - **Description**: 力扣 牛客 刷题记录 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-11-09 - **Last Updated**: 2023-06-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LeetCode 笔记 ### 1.两数之和 初始化数组方法 `return new int[]{i, j};` > 用空间换时间 (哈希表实现的查找表) - 在哈希表中查看是否存在一个键是(O1)的 ### 2.两数相加 > 递归 ``` class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { return add(l1, l2, 0); } /** 返回两个链表相加的头部 */ public ListNode add(ListNode l1, ListNode l2, int bit) { if (l1 == null && l2 == null && bit == 0) { return null; } int val = bit; if (l1 != null) { val += l1.val; l1 = l1.next; } if (l2 != null) { val += l2.val; l2 = l2.next; } ListNode node = new ListNode(val % 10); node.next = add(l1, l2, val / 10); return node; } } ``` ### 3.最长子串 > 滑动窗口 哈希集 哈希表 ### 14 最长公共前缀 > 分治,递归 ### 48.旋转矩阵 可以通过(r,c)用脑子想怎么移动的,画图进行旋转和数的想象列出数学关系。