力扣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;
      }
  };
相关推荐
CoderYanger1 分钟前
递归、搜索与回溯-记忆化搜索:38.最长递增子序列
java·算法·leetcode·1024程序员节
面试鸭7 分钟前
科大讯飞,你好大方。。。
java·计算机·职场和发展·求职招聘
xlq223221 小时前
22.多态(下)
开发语言·c++·算法
CoderYanger1 小时前
C.滑动窗口-越短越合法/求最长/最大——2958. 最多 K 个重复元素的最长子数组
java·数据结构·算法·leetcode·哈希算法·1024程序员节
却话巴山夜雨时i2 小时前
394. 字符串解码【中等】
java·数据结构·算法·leetcode
haing20192 小时前
使用黄金分割法计算Bezier曲线曲率极值的方法介绍
算法·黄金分割
leoufung2 小时前
LeetCode 230:二叉搜索树中第 K 小的元素 —— 从 Inorder 遍历到 Order Statistic Tree
算法·leetcode·职场和发展
jyyyx的算法博客2 小时前
多模字符串匹配算法 -- 面试题 17.17. 多次搜索
算法
da_vinci_x2 小时前
Sampler AI + 滤波算法:解决 AIGC 贴图“噪点过剩”,构建风格化 PBR 工业管线
人工智能·算法·aigc·材质·贴图·技术美术·游戏美术
惊鸿.Jh2 小时前
503. 下一个更大元素 II
数据结构·算法·leetcode