力扣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;
      }
  };
相关推荐
稚辉君.MCA_P8_Java11 分钟前
Gemini永久会员 Java实现的暴力递归版本
java·数据结构·算法
冯诺依曼的锦鲤22 分钟前
算法练习:差分
c++·学习·算法
有意义1 小时前
栈数据结构全解析:从实现原理到 LeetCode 实战
javascript·算法·编程语言
鹿鹿鹿鹿isNotDefined1 小时前
逐步手写,实现符合 Promise A+ 规范的 Promise
前端·javascript·算法
封奚泽优1 小时前
下降算法(Python实现)
开发语言·python·算法
im_AMBER1 小时前
算法笔记 16 二分搜索算法
c++·笔记·学习·算法
高洁011 小时前
【无标具身智能-多任务与元学习】
神经网络·算法·aigc·transformer·知识图谱
leoufung1 小时前
逆波兰表达式 LeetCode 题解及相关思路笔记
linux·笔记·leetcode
识醉沉香2 小时前
广度优先遍历
算法·宽度优先
中國龍在廣州2 小时前
现在人工智能的研究路径可能走反了
人工智能·算法·搜索引擎·chatgpt·机器人