力扣2251.花期内花的数目

力扣2251.花期内花的数目

  • 差分

    • 1e9数据范围优雅的写法
cpp 复制代码
  class Solution {
  public:
      vector<int> fullBloomFlowers(vector<vector<int>>& flowers, vector<int>& persons) {
          map<int,int> mp;
          for(auto &it:flowers) mp[it[0]] ++ , mp[it[1] + 1] --;
          for(auto x:persons) mp[x];
  
          int tot = 0;
          for(auto &[x,y] : mp)
              y = (tot += y);
          for(auto &x:persons)
              x = mp[x];
          return persons;
      }
  };
相关推荐
小冉在学习30 分钟前
leetcode刷题day13|二叉树Part01(递归遍历、迭代遍历、统一迭代、层序遍历)
算法·leetcode·职场和发展
我就想睡到自然醒30 分钟前
《UniVS: Unified and Universal Video Segmentation with Prompts as Queries》要点提炼
人工智能·算法·机器学习
A.A呐40 分钟前
LeetCode 692.前K个高频单词
c++·算法·leetcode
小冉在学习1 小时前
leetcode刷题day17|二叉树Part05(654.最大二叉树、617.合并二叉树、700.二叉搜索树中的搜索、98.验证二叉搜索树)
数据结构·算法·leetcode
_Power_Y1 小时前
JavaSE:4、流程控制
java·开发语言·算法
Once_day1 小时前
代码训练LeetCode(18)多数元素
算法·leetcode
zzt_is_me1 小时前
c++的静态成员
java·c++·算法
DdddJMs__1352 小时前
C语言 | Leetcode C语言题解之第402题移掉K位数字
c语言·leetcode·题解
阿诚学java2 小时前
数据结构与算法-17高级数据结构_图论(迪杰斯特拉算法)
数据结构·算法·图论
小L~~~2 小时前
2024年华为9月4日秋招笔试真题题解
c++·算法