=======简单

leetcode164 Maximum Gap sort两次

=======有参考

330 Patching Array

98 Validate Binary Search Tree BFS

60 Subsets II [done]

435 non-overlapping

public int eraseOverlapIntervals(Interval[] intervals) {
if (intervals == null || intervals.length == 0){
return 0;
}
Arrays.sort(intervals, new IntervalCompare());
int end = intervals[0].end;
int prev = 0;
int count = 0;
for(int i = 1; i < intervals.length; i++){
if(intervals[prev].end > intervals[i].start){
if(intervals[prev].end > intervals[i].end){
prev = i;
}
count++;
}
else{
prev =
i;
}

}
return count;
}

455. Assign Cookies

class Solution {
public int findContentChildren(int[] g, int[] s) {
if(g == null || g.length == 0)return 0;
if(s == null || s.length == 0)return 0;
Arrays.sort(g);
Arrays.sort(s);
int cnt=0;
int i=0;
for(int gg:g){
while(i<s.length && gg>s[i]) i++;
if(i==s.length) break;
cnt++;
i++;
}
return cnt;
}
}

[leetcode整理]的更多相关文章

  1. leetcode整理(一)

    leetcode题目整理,基本上不是最优解 1. 回文数 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121 输出: true 示例 ...

  2. leetcode 整理

    1.Two Sum 构造Comparator,KSum 这一类的问题最基本的一题, 解法: 先sort,然后双指针,头尾各一个.进行加逼找值. 对于其余的KSum最终是降次到2次. 如3Sum固定一个 ...

  3. LeetCode 到底怎么刷?GitHub 上多位大厂程序员亲测的高效刷题方式

    作者:HelloGitHub-小鱼干 在众多的诸如阿里.腾讯等大厂之中,最看中面试者刷题技能的大概要数有"链表厂"之称的字节跳动了.作为一个新晋大厂,字节跳动以高薪.技术大佬云集吸 ...

  4. Leetcode——回溯法常考算法整理

    Leetcode--回溯法常考算法整理 Preface Leetcode--回溯法常考算法整理 Definition Why & When to Use Backtrakcing How to ...

  5. Leetcode——二叉树常考算法整理

    二叉树常考算法整理 希望通过写下来自己学习历程的方式帮助自己加深对知识的理解,也帮助其他人更好地学习,少走弯路.也欢迎大家来给我的Github的Leetcode算法项目点star呀~~ 二叉树常考算法 ...

  6. ACM金牌选手整理的【LeetCode刷题顺序】

    算法和数据结构知识点图 首先,了解算法和数据结构有哪些知识点,在后面的学习中有 大局观,对学习和刷题十分有帮助. 下面是我花了一天时间花的算法和数据结构的知识结构,大家可以看看. 后面是为大家 精心挑 ...

  7. [leetcode] 提醒整理之进制

    12. Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be with ...

  8. [leetcode] 题型整理之二叉树

    94. Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes' va ...

  9. [leetcode] 题型整理之动态规划

    动态规划属于技巧性比较强的题目,如果看到过原题的话,对解题很有帮助 55. Jump Game Given an array of non-negative integers, you are ini ...

随机推荐

  1. Superclass和Constructor Chaining

    A subclass inherits accessible date fields and methods from its superclass. Does it inherit construc ...

  2. 单细胞RNA-seq比对定量用什么工具好?使用哪个版本的基因组?数据来说话

    这么多工具和基因组版本,选择困难症犯了,到底用哪个好呢? 2018 nature - Developmental diversification of cortical inhibitory inte ...

  3. Java类成员变量的默认值

    1.布尔型(boolean)变量默认值为false,byte.short.int.long为0,字符型为'\u0000'(空字符),浮点型(float double)为0.0,引用类型(String) ...

  4. drf 需求案例1

    案例: 实现过程: 1. 创建一个项目: django-adim startproject dfr3 2.  创建 一个app    homwork python manage.py startapp ...

  5. 廖雪峰网站:学习python函数—定义函数(二)

    def my_abs(x): if x >= 0: return x else: return -x print(my_abs(-99)) # 空函数 def nop(): pass # 参数检 ...

  6. 函数和函数模版在一个。cpp中的情况!(除了左移和右移,其他的不要用友元函数!!!)

    // 友元函数和运算符重载的碰撞.cpp : 定义控制台应用程序的入口点. // #include <iostream> using namespace std; template < ...

  7. java解析前端请求接口的全部入参

    第一种: public static String getRequestInput(HttpServletRequest request) { StringBuilder sb = new Strin ...

  8. Oracle PL/SQL异常、存储过程和触发器

    一.异常 1.处理异常 (1)除数不为0 declare b number; begin b:; exception when zero_divide then dbms_output.put_lin ...

  9. 牛客练习赛32-D-MST+tarjin割边

    链接:https://ac.nowcoder.com/acm/contest/272/D来源:牛客网 题目描述 小p和他的朋友约定好去游乐场游玩,但是他们到了游乐场后却互相找不到对方了. 游乐场可以看 ...

  10. 12. Integer to Roman C++

    直接将各个数位上每个数所代表的罗马数字表示成字符串数组,然后提取出num的各位数,将对应的string相加 class Solution { public: string intToRoman(int ...