![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode 做题记
瞌睡大王不是我
这个作者很懒,什么都没留下…
展开
-
Leetcode 1. Two Sum
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the answer.原创 2020-10-21 10:33:51 · 120 阅读 · 0 评论 -
leetcode笔记 - 275.H指数II (H-Index II)
Leetcode 275. H-Index II没想到这个题也可以用二分法做,真是惊喜,可能自己做的题还不够,一时没想到用二分法,就感觉很有意思 哈哈哈我的第一想法有顺序嘛,那就从开头一直向后找 哈哈哈 暴力,咦 难怪最近看新闻报道某厂 男 暴力女友,哎 算法题做多了呗,算法不提倡暴力,生活也不提倡哈 生活不易 请有缘人互相珍惜呀。class Solution { public int hIndex(int[] citations) { int i = 0;原创 2020-06-19 12:45:24 · 142 阅读 · 0 评论 -
Leetcode - 509. 斐波那契数
// 斐波那契数Fibonacci 数列 是最典型的让我们了解递归算法的例子。递归核心:1. 递归关系表达式2. 递归终止条件直观的递归,调用自身很多次重复计算,不提倡。class Solution { public int fib(int N) { if (N == 0) return 0; if (N == 1) return 1; return fib(N-1)+fib(N-2); }}递归 + memo原创 2020-06-12 03:34:16 · 148 阅读 · 0 评论 -
Leetcode - 75. 颜色分类
Leetcode 75. 颜色分类1.快速排序2.插入排序快速排序(partition)定义两个变量one、two 一次将数组分层三个部分:[0, one) 区间存放 0;[one, two) 区间存放 1;[two, len) 区间存放 2。定义一个 移动变量 i 来辅助遍历多有的数据。public class LC75ColorSort { public static void main(String[] args) { int[] nums = {2, 0原创 2020-06-12 01:09:35 · 147 阅读 · 0 评论