=======简单

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. 动态规划-Race Car

    2018-10-26 21:06:54 问题描述: 问题求解: 方法一.BFS 首先将使用BFS进行解空间的遍历,也就是将本问题转化成了搜索问题,但是有两个地方需要注意: 1.状态保存的问题,每个位置 ...

  2. nodejs初识

    提到nodejs总离不开npm,因此首先要学些和了解npm.而对于npm.nodejs的了解都来源于菜鸟教程. nodejs学习地址:http://www.runoob.com/nodejs/node ...

  3. C#内存压缩zip文件

    C#中我们使用比较多的文件压缩第三方DLL就是Ionic.Utils.Zip.dll.但是这个DLL只支持对现有文件进行压缩,而不支持内存压缩,如果需要使用内存压缩,那么有第三方DLL ICSharp ...

  4. firewalld管理防火墙常用命令

    1.查看防火墙的状态 [root@localhost HMK]# firewall-cmd --state 查看防火墙的运行状态 not running [root@localhost HMK]# s ...

  5. .bat文件的用途

    bat(batch) .bat文件是用来干什么的?我们可以通过win+r,进入cmd,用dos命令行来完成某些操作,比如ping. 我们这里可以用更简单的办法,可以把命令行写入记事本,然后修改后缀为b ...

  6. 雷林鹏分享:jQuery EasyUI 数据网格 - 添加分页组件

    jQuery EasyUI 数据网格 - 添加分页组件 本实例演示如何从服务器端加载数据,如何添加分页组件(pagination)到数据网格(datagrid). 创建数据网格(DataGrid) 为 ...

  7. mac下 配置homebrew 和java home

    1.terminal下输入   /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/insta ...

  8. 女性睾酮水平高(High Testosterone Levels in Women)

    在外国网站了解睾酮高的一些资料,顺便记录生活点滴. 摘自网址:https://www.healthline.com/health/high-testosterone-in-women 高睾酮的妇女 睾 ...

  9. python中RabbitMQ的使用(远程过程调用RPC)

    在RabbitMQ消息队列中,往往接收者.发送者不止是一个身份.例如接接收者收到消息并且需要返回给发送者. 此时接收者.发送者的身份不再固定! 我们来模拟该情形: 假设有客户端client,服务端se ...

  10. [LeetCode] Network Delay Time 网络延迟时间——最短路算法 Bellman-Ford(DP) 和 dijkstra(本质上就是BFS的迭代变种)

    There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges ti ...