当前位置: 首页 > news >正文

哈希表题目:设计地铁系统

文章目录

  • 题目
    • 标题和出处
    • 难度
    • 题目描述
      • 要求
      • 示例
      • 数据范围
  • 解法
    • 思路和算法
    • 代码
    • 复杂度分析

题目

标题和出处

标题:设计地铁系统

出处:1396. 设计地铁系统

难度

6 级

题目描述

要求

一个地铁系统正在收集乘客在不同站之间的花费时间。他们在使用这些数据计算从一个地铁站到另一个地铁站的平均花费时间。

实现 UndergroundSystem \texttt{UndergroundSystem} UndergroundSystem 类:

  • void checkIn(int id, string stationName, int t) \texttt{void checkIn(int id, string stationName, int t)} void checkIn(int id, string stationName, int t)
    • 卡号为 id \texttt{id} id 的乘客在 t \texttt{t} t 时刻进入地铁站 stationName \texttt{stationName} stationName
    • 一个乘客在同一时间只能进入一个地点。
  • void checkOut(int id, string stationName, int t) \texttt{void checkOut(int id, string stationName, int t)} void checkOut(int id, string stationName, int t)
    • 卡号为 id \texttt{id} id 的乘客在 t \texttt{t} t 时刻离开地铁站 stationName \texttt{stationName} stationName
  • double getAverageTime(string startStation, string endStation) \texttt{double getAverageTime(string startStation, string endStation)} double getAverageTime(string startStation, string endStation)
    • 返回从地铁站 startStation \texttt{startStation} startStation 到地铁站 endStation \texttt{endStation} endStation 的平均花费时间。
    • 平均时间计算的行程包括当前为止所有从 startStation \texttt{startStation} startStation 直接到达 endStation \texttt{endStation} endStation 的行程,即进入地铁站 startStation \texttt{startStation} startStation 之后离开地铁站 endStation \texttt{endStation} endStation
    • 从地铁站 startStation \texttt{startStation} startStation 到地铁站 endStation \texttt{endStation} endStation 的花费时间可能不同于从地铁站 endStation \texttt{endStation} endStation 到地铁站 startStation \texttt{startStation} startStation 的花费时间。
    • 调用 getAverageTime \texttt{getAverageTime} getAverageTime 时,至少已经有一个乘客从地铁站 startStation \texttt{startStation} startStation 乘坐到地铁站 endStation \texttt{endStation} endStation

你可以假设所有对 checkIn \texttt{checkIn} checkIn checkOut \texttt{checkOut} checkOut 的调用都是符合逻辑的。如果一个乘客在 t 1 \texttt{t}_\texttt{1} t1 时刻进入某个地铁站并在 t 2 \texttt{t}_\texttt{2} t2 时刻离开某个地铁站,那么 t 1 < t 2 \texttt{t}_\texttt{1} < \texttt{t}_\texttt{2} t1<t2。所有的事件都按时间顺序给出。

示例

示例 1:

输入:
["UndergroundSystem","checkIn","checkIn","checkIn","checkOut","checkOut","checkOut","getAverageTime","getAverageTime","checkIn","getAverageTime","checkOut","getAverageTime"] \texttt{["UndergroundSystem","checkIn","checkIn","checkIn","checkOut","checkOut","checkOut","getAverageTime","getAverageTime","checkIn","getAverageTime","checkOut","getAverageTime"]} ["UndergroundSystem","checkIn","checkIn","checkIn","checkOut","checkOut","checkOut","getAverageTime","getAverageTime","checkIn","getAverageTime","checkOut","getAverageTime"]
[[],[45,"Leyton",3],[32,"Paradise",8],[27,"Leyton",10],[45,"Waterloo",15],[27,"Waterloo",20],[32,"Cambridge",22],["Paradise","Cambridge"],["Leyton","Waterloo"],[10,"Leyton",24],["Leyton","Waterloo"],[10,"Waterloo",38],["Leyton","Waterloo"]] \texttt{[[],[45,"Leyton",3],[32,"Paradise",8],[27,"Leyton",10],[45,"Waterloo",15],[27,"Waterloo",20],[32,"Cambridge",22],["Paradise","Cambridge"],["Leyton","Waterloo"],[10,"Leyton",24],["Leyton","Waterloo"],[10,"Waterloo",38],["Leyton","Waterloo"]]} [[],[45,"Leyton",3],[32,"Paradise",8],[27,"Leyton",10],[45,"Waterloo",15],[27,"Waterloo",20],[32,"Cambridge",22],["Paradise","Cambridge"],["Leyton","Waterloo"],[10,"Leyton",24],["Leyton","Waterloo"],[10,"Waterloo",38],["Leyton","Waterloo"]]
输出:
[null,null,null,null,null,null,null,14.00000,11.00000,null,11.00000,null,12.00000] \texttt{[null,null,null,null,null,null,null,14.00000,11.00000,null,11.00000,null,12.00000]} [null,null,null,null,null,null,null,14.00000,11.00000,null,11.00000,null,12.00000]
解释:
UndergroundSystem undergroundSystem = new UndergroundSystem(); \texttt{UndergroundSystem undergroundSystem = new UndergroundSystem();} UndergroundSystem undergroundSystem = new UndergroundSystem();
undergroundSystem.checkIn(45, "Leyton", 3); \texttt{undergroundSystem.checkIn(45, "Leyton", 3);} undergroundSystem.checkIn(45, "Leyton", 3);
undergroundSystem.checkIn(32, "Paradise", 8); \texttt{undergroundSystem.checkIn(32, "Paradise", 8);} undergroundSystem.checkIn(32, "Paradise", 8);
undergroundSystem.checkIn(27, "Leyton", 10); \texttt{undergroundSystem.checkIn(27, "Leyton", 10);} undergroundSystem.checkIn(27, "Leyton", 10);
undergroundSystem.checkOut(45, "Waterloo", 15); \texttt{undergroundSystem.checkOut(45, "Waterloo", 15);} undergroundSystem.checkOut(45, "Waterloo", 15); // 乘客 45 \texttt{45} 45 "Leyton" \texttt{"Leyton"} "Leyton" "Waterloo" \texttt{"Waterloo"} "Waterloo" 的时间是 15 - 3 = 12 \texttt{15 - 3 = 12} 15 - 3 = 12
undergroundSystem.checkOut(27, "Waterloo", 20); \texttt{undergroundSystem.checkOut(27, "Waterloo", 20);} undergroundSystem.checkOut(27, "Waterloo", 20); // 乘客 27 \texttt{27} 27 "Leyton" \texttt{"Leyton"} "Leyton" "Waterloo" \texttt{"Waterloo"} "Waterloo" 的时间是 20 - 10 = 10 \texttt{20 - 10 = 10} 20 - 10 = 10
undergroundSystem.checkOut(32, "Cambridge", 22); \texttt{undergroundSystem.checkOut(32, "Cambridge", 22);} undergroundSystem.checkOut(32, "Cambridge", 22); // 乘客 32 \texttt{32} 32 "Paradise" \texttt{"Paradise"} "Paradise" "Cambridge" \texttt{"Cambridge"} "Cambridge" 的时间是 22 - 8 = 14 \texttt{22 - 8 = 14} 22 - 8 = 14
undergroundSystem.getAverageTime("Paradise", "Cambridge"); \texttt{undergroundSystem.getAverageTime("Paradise", "Cambridge");} undergroundSystem.getAverageTime("Paradise", "Cambridge"); // 返回 14.00000 \texttt{14.00000} 14.00000。从 "Paradise" \texttt{"Paradise"} "Paradise" "Cambridge" \texttt{"Cambridge"} "Cambridge" 的行程有 1 \texttt{1} 1 个, (14) / 1 = 14 \texttt{(14) / 1 = 14} (14) / 1 = 14
undergroundSystem.getAverageTime("Leyton", "Waterloo"); \texttt{undergroundSystem.getAverageTime("Leyton", "Waterloo");} undergroundSystem.getAverageTime("Leyton", "Waterloo"); // 返回 11.00000 \texttt{11.00000} 11.00000。从 "Leyton" \texttt{"Leyton"} "Leyton" "Waterloo" \texttt{"Waterloo"} "Waterloo" 的行程有 2 \texttt{2} 2 个, (10 + 12) / 2 = 11 \texttt{(10 + 12) / 2 = 11} (10 + 12) / 2 = 11
undergroundSystem.checkIn(10, "Leyton", 24); \texttt{undergroundSystem.checkIn(10, "Leyton", 24);} undergroundSystem.checkIn(10, "Leyton", 24);
undergroundSystem.getAverageTime("Leyton", "Waterloo"); \texttt{undergroundSystem.getAverageTime("Leyton", "Waterloo");} undergroundSystem.getAverageTime("Leyton", "Waterloo"); // 返回 11.00000 \texttt{11.00000} 11.00000
undergroundSystem.checkOut(10, "Waterloo", 38); \texttt{undergroundSystem.checkOut(10, "Waterloo", 38);} undergroundSystem.checkOut(10, "Waterloo", 38); // 乘客 10 \texttt{10} 10 "Leyton" \texttt{"Leyton"} "Leyton" "Waterloo" \texttt{"Waterloo"} "Waterloo" 的时间是 38 - 24 = 14 \texttt{38 - 24 = 14} 38 - 24 = 14
undergroundSystem.getAverageTime("Leyton", "Waterloo"); \texttt{undergroundSystem.getAverageTime("Leyton", "Waterloo");} undergroundSystem.getAverageTime("Leyton", "Waterloo"); // 返回 12.00000 \texttt{12.00000} 12.00000。从 "Leyton" \texttt{"Leyton"} "Leyton" "Waterloo" \texttt{"Waterloo"} "Waterloo" 的行程有 3 \texttt{3} 3 个, (10 + 12 + 14) / 3 = 12 \texttt{(10 + 12 + 14) / 3 = 12} (10 + 12 + 14) / 3 = 12

示例 2:

输入:
["UndergroundSystem","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime"] \texttt{["UndergroundSystem","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime"]} ["UndergroundSystem","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime","checkIn","checkOut","getAverageTime"]
[[],[10,"Leyton",3],[10,"Paradise",8],["Leyton","Paradise"],[5,"Leyton",10],[5,"Paradise",16],["Leyton","Paradise"],[2,"Leyton",21],[2,"Paradise",30],["Leyton","Paradise"]] \texttt{[[],[10,"Leyton",3],[10,"Paradise",8],["Leyton","Paradise"],[5,"Leyton",10],[5,"Paradise",16],["Leyton","Paradise"],[2,"Leyton",21],[2,"Paradise",30],["Leyton","Paradise"]]} [[],[10,"Leyton",3],[10,"Paradise",8],["Leyton","Paradise"],[5,"Leyton",10],[5,"Paradise",16],["Leyton","Paradise"],[2,"Leyton",21],[2,"Paradise",30],["Leyton","Paradise"]]
输出:
[null,null,null,5.00000,null,null,5.50000,null,null,6.66667] \texttt{[null,null,null,5.00000,null,null,5.50000,null,null,6.66667]} [null,null,null,5.00000,null,null,5.50000,null,null,6.66667]
解释:
UndergroundSystem undergroundSystem = new UndergroundSystem(); \texttt{UndergroundSystem undergroundSystem = new UndergroundSystem();} UndergroundSystem undergroundSystem = new UndergroundSystem();
undergroundSystem.checkIn(10, "Leyton", 3); \texttt{undergroundSystem.checkIn(10, "Leyton", 3);} undergroundSystem.checkIn(10, "Leyton", 3);
undergroundSystem.checkOut(10, "Paradise", 8); \texttt{undergroundSystem.checkOut(10, "Paradise", 8);} undergroundSystem.checkOut(10, "Paradise", 8); // 乘客 10 \texttt{10} 10 "Leyton" \texttt{"Leyton"} "Leyton" "Paradise" \texttt{"Paradise"} "Paradise" 的时间是 8 - 3 = 5 \texttt{8 - 3 = 5} 8 - 3 = 5
undergroundSystem.getAverageTime("Leyton", "Paradise"); \texttt{undergroundSystem.getAverageTime("Leyton", "Paradise");} undergroundSystem.getAverageTime("Leyton", "Paradise"); // 返回 5.00000 \texttt{5.00000} 5.00000 (5) / 1 = 5 \texttt{(5) / 1 = 5} (5) / 1 = 5
undergroundSystem.checkIn(5, "Leyton", 10); \texttt{undergroundSystem.checkIn(5, "Leyton", 10);} undergroundSystem.checkIn(5, "Leyton", 10);
undergroundSystem.checkOut(5, "Paradise", 16); \texttt{undergroundSystem.checkOut(5, "Paradise", 16);} undergroundSystem.checkOut(5, "Paradise", 16); // 乘客 5 \texttt{5} 5 "Leyton" \texttt{"Leyton"} "Leyton" "Paradise" \texttt{"Paradise"} "Paradise" 的时间是 16 - 10 = 6 \texttt{16 - 10 = 6} 16 - 10 = 6
undergroundSystem.getAverageTime("Leyton", "Paradise"); \texttt{undergroundSystem.getAverageTime("Leyton", "Paradise");} undergroundSystem.getAverageTime("Leyton", "Paradise"); // 返回 5.50000 \texttt{5.50000} 5.50000 (5 + 6) / 2 = 5.5 \texttt{(5 + 6) / 2 = 5.5} (5 + 6) / 2 = 5.5
undergroundSystem.checkIn(2, "Leyton", 21); \texttt{undergroundSystem.checkIn(2, "Leyton", 21);} undergroundSystem.checkIn(2, "Leyton", 21);
undergroundSystem.checkOut(2, "Paradise", 30); \texttt{undergroundSystem.checkOut(2, "Paradise", 30);} undergroundSystem.checkOut(2, "Paradise", 30); // 乘客 2 \texttt{2} 2 "Leyton" \texttt{"Leyton"} "Leyton" "Paradise" \texttt{"Paradise"} "Paradise" 的时间是 30 - 21 = 9 \texttt{30 - 21 = 9} 30 - 21 = 9
undergroundSystem.getAverageTime("Leyton", "Paradise"); \texttt{undergroundSystem.getAverageTime("Leyton", "Paradise");} undergroundSystem.getAverageTime("Leyton", "Paradise"); // 返回 6.66667 \texttt{6.66667} 6.66667 (5 + 6 + 9) / 3 = 6.66667 \texttt{(5 + 6 + 9) / 3 = 6.66667} (5 + 6 + 9) / 3 = 6.66667

数据范围

  • 1 ≤ id, t ≤ 10 6 \texttt{1} \le \texttt{id, t} \le \texttt{10}^\texttt{6} 1id, t106
  • 1 ≤ stationName.length, startStation.length, endStation.length ≤ 10 \texttt{1} \le \texttt{stationName.length, startStation.length, endStation.length} \le \texttt{10} 1stationName.length, startStation.length, endStation.length10
  • 所有的字符串包含大写字母、小写字母和数字
  • 总共最多调用 2 × 10 4 \texttt{2} \times \texttt{10}^\texttt{4} 2×104 checkIn \texttt{checkIn} checkIn checkOut \texttt{checkOut} checkOut getAverageTime \texttt{getAverageTime} getAverageTime
  • 与标准答案误差在 10 -5 \texttt{10}^\texttt{-5} 10-5 以内的结果都视为正确结果

解法

思路和算法

这道题要求收集乘客在不同站之间的花费时间,并根据这些数据计算从一个地铁站到另一个地铁站的平均花费时间。

一个乘客在 t 1 t_1 t1 时刻进入地铁站 s 1 s_1 s1,然后在 t 2 t_2 t2 时刻离开地铁站 s 2 s_2 s2,则该乘客从地铁站 s 1 s_1 s1 到地铁站 s 2 s_2 s2 的花费时间是 t 2 − t 1 t_2 - t_1 t2t1。为了记录乘客在不同站之间的花费时间,需要使用哈希表记录每个乘客的卡号以及该乘客进入的地铁站和进站时刻,当乘客离开另一个地铁站时,可以根据乘客的卡号得到该乘客进入的地铁站和进站时刻,结合乘客离开的地铁站和出站时刻即可得到由起点和终点组成的旅程信息,以及花费时间。

为了计算两个特定地铁站之间的平均花费时间,需要使用哈希表记录每个旅程以及该旅程的总时间与次数。当乘客离开地铁站时,即可得到该乘客的旅程信息和花费时间,将该旅程的总时间加上该乘客的花费时间,将该旅程的次数加 1 1 1,总时间除以次数即为该旅程的平均花费时间。

基于上述分析,需要维护两个哈希表,分别记录进站信息和旅程时间。

构造方法中,将两个哈希表初始化。

对于 checkIn \textit{checkIn} checkIn 操作,根据站名和时刻构造进站信息,将卡号和进站信息存入进站信息哈希表。

对于 checkOut \textit{checkOut} checkOut 操作,根据卡号 id \textit{id} id 从进站信息哈希表中得到进站信息,从进站信息得到进入的地铁站 startStation \textit{startStation} startStation 和进站时刻 startTime \textit{startTime} startTime,结合离开的地铁站 stationName \textit{stationName} stationName 和出站时刻 t t t,得到旅程为进入的地铁站和离开的地铁站拼接之后的字符串,花费时间为 t − startTime t - \textit{startTime} tstartTime,将旅程和花费时间存入旅程时间哈希表。

对于 getAverageTime \textit{getAverageTime} getAverageTime 操作,根据进入的地铁站 startStation \textit{startStation} startStation 和离开的地铁站 endStation \textit{endStation} endStation 得到旅程,从旅程时间哈希表中得到该旅程的总时间与次数,总时间除以次数即为该旅程的平均花费时间。

由于所有的事件都按时间顺序出现,同一个乘客一定是先进站后出站,当一个乘客出站之后,不可能在进站之前第二次出站,因此当乘客出站时,不需要将该乘客的进站信息从进站信息哈希表中删除。

代码

class UndergroundSystem {private class CheckInInfo {private String station;private int time;public CheckInInfo(String station, int time) {this.station = station;this.time = time;}public String getStation() {return station;}public int getTime() {return time;}}private Map<Integer, CheckInInfo> checkInMap;private Map<String, int[]> tripTimeMap;public UndergroundSystem() {checkInMap = new HashMap<Integer, CheckInInfo>();tripTimeMap = new HashMap<String, int[]>();}public void checkIn(int id, String stationName, int t) {CheckInInfo info = new CheckInInfo(stationName, t);checkInMap.put(id, info);}public void checkOut(int id, String stationName, int t) {CheckInInfo info = checkInMap.get(id);String startStation = info.getStation();int startTime = info.getTime();String key = startStation + "," + stationName;tripTimeMap.putIfAbsent(key, new int[2]);int[] time = tripTimeMap.get(key);time[0] += t - startTime;time[1]++;}public double getAverageTime(String startStation, String endStation) {String key = startStation + "," + endStation;int[] time = tripTimeMap.get(key);return 1.0 * time[0] / time[1];}
}

复杂度分析

  • 时间复杂度:构造方法和各项操作的时间复杂度都是 O ( 1 ) O(1) O(1)。构造方法初始化两个哈希表,各项操作均为操作哈希表和计算花费时间,因此时间复杂度是 O ( 1 ) O(1) O(1)。这里将字符串操作的时间视为 O ( 1 ) O(1) O(1)

  • 空间复杂度: O ( n ) O(n) O(n),其中 n n n 是所有方法的总调用次数。需要使用两个哈希表分别记录进站信息和旅程时间,每个哈希表中的元素个数都是 O ( n ) O(n) O(n)

相关文章:

哈希表题目:设计地铁系统

文章目录 题目标题和出处难度题目描述要求示例数据范围 解法思路和算法代码复杂度分析 题目 标题和出处 标题&#xff1a;设计地铁系统 出处&#xff1a;1396. 设计地铁系统 难度 6 级 题目描述 要求 一个地铁系统正在收集乘客在不同站之间的花费时间。他们在使用这些数…...

云时通OMS:为零售品牌商打造高效的全渠道订单管理!

传统的零售企业围绕“人、货、场” 三要素来展开营销&#xff0c;其目标是基于“场”将货销售给更多的人。随着数字技术的应用&#xff0c;新零售模式下的“场”除了传统的线下店铺外&#xff0c;还拓展了多元化的线上渠道&#xff0c;比如小程序、企业APP、第三方平台、电商直…...

有必要给孩子买台灯吗?分享四款高品质的护眼台灯

有必要使用护眼台灯&#xff0c;尤其是有近视现象的孩子们。 现在很多孩子小学就开始近视了&#xff0c;保护视力刻不容缓呀! 很多人不知道&#xff0c;其实劣质光线是最大的眼睛杀手 给孩子随便买便宜的台灯&#xff0c;看着一样能用&#xff0c;其实时间久了 对孩子眼睛的…...

模板方法模式

模板方法模式 模板方法模式定义:使用场景角色定义抽象模板: 为抽象模板&#xff0c;它的方法分为两类AbstractClass1. 基本方法: 也叫做基本操作&#xff0c;是由子类实现的方法&#xff0c;并且在模板方法被调用。2. 模板方法: 可以有一个或几个&#xff0c;一般是一个具体方法…...

基于Yolov5的NEU-DET钢材表面缺陷检测,优化组合新颖程度较高:CVPR2023 DCNV3和InceptionNeXt,涨点明显

1.钢铁缺陷数据集介绍 NEU-DET钢材表面缺陷共有六大类,分别为:crazing,inclusion,patches,pitted_surface,rolled-in_scale,scratches 每个类别分布为: 训练结果如下: 2.基于yolov5s的训练 map值: 2.1 Inception-MetaNeXtStage 对应博客:https://cv2023.blog.csdn.n…...

【HarmonyOS】自定义组件之ArkUI实现通用标题栏组件

【关键字】 标题栏、常用内置组件整合、ArkUI、自定义组件 1、写在前面 在上一篇文章中我们通过Java语言实现了一个通用的标题栏组件&#xff0c;有需要的可以看下&#xff0c;文章地址&#xff1a; 华为开发者论坛 现在很多朋友都已经转战ArkTS语言了&#xff0c;那么今天…...

C#开发的OpenRA游戏的加载地图流程

C#开发的OpenRA游戏的加载地图流程 OpenRA游戏里,地图是一个很关键的数据, 因为地图里包括了地面状态,地面上建筑物状态, 还有玩家在地图上的布局情况,以及各种活动限制的条件。 在OpenRA里,需要把地图目录:OpenRA\mods\cnc\maps 里所有的文件进行加载, 并且保存在缓…...

python ast 详解与用法

目录 基本概念节点类型ast.Assignast.Nameast.Constantast.Callast.Attribute 结点的遍历ast源码示例 结点的修改示例 参考链接 基本概念 在 python 中&#xff0c;我们可以通过自带的 ast 模块来对解析遍历语法树&#xff0c;通过ast.parse()可以将字符串代码解析为抽象语法树…...

Go语言开发小技巧易错点100例(七)

往期回顾&#xff1a; Go语言开发小技巧&易错点100例&#xff08;一&#xff09;Go语言开发小技巧&易错点100例&#xff08;二&#xff09;Go语言开发小技巧&易错点100例&#xff08;三&#xff09;Go语言开发小技巧&易错点100例&#xff08;四&#xff09;Go…...

爬虫为什么需要ip

爬虫需要使用爬虫ip主要是为了解决以下问题&#xff1a; 1、反爬虫机制&#xff1a;许多网站会设置反爬虫机制来防止爬虫程序的访问&#xff0c;例如限制IP地址的访问频率、检测访问来源等。使用爬虫ip可以绕过这些限制&#xff0c;使得爬虫程序更难被检测到。 2、访问限制&a…...

RabbitMQ-保证消息可靠性

RabbitMQ-保证消息可靠性 1.消息可靠性1.1.生产者消息确认1.1.1.修改配置1.1.2.定义Return回调1.1.3.定义ConfirmCallback 1.2.消息持久化1.2.1.交换机持久化1.2.2.队列持久化1.2.3.消息持久化 1.3.消费者消息确认1.3.1.演示none模式1.3.2.演示auto模式 1.4.消费失败重试机制1.…...

Python教程——Python本地环境安装

文章目录 简介安装Python下载安装验证安装结果 手动添加环境变量安装问题 简介 python官网&#xff1a;https://www.python.org/ Python Windows下载地址&#xff1a;https://www.python.org/downloads/windows/ Python 官方文档&#xff1a;https://www.python.org/doc/ Pytho…...

“智慧交通”转型升级+创新发展策略

随着“互联网交通”的应用创新推陈出新&#xff0c;传统轨道交通行业客户服务中心已难以满足乘客对便捷高效的客户服务需求&#xff1b;节假日人流量激增&#xff0c;客户服务人手不足&#xff0c;交通、站点堵塞、信息更新不及时等问题是常态。因此&#xff0c;“智慧城市”交…...

华为OD机试 - 开放日活动、取出尽量少的球(Python)

题目描述 某部门开展Family Day开放日活动,其中有个从桶里取球的游戏,游戏规则如下: 有N个容量一样的小桶等距排开, 且每个小桶都默认装了数量不等的小球, 每个小桶装的小球数量记录在数组 bucketBallNums 中, 游戏开始时,要求所有桶的小球总数不能超过SUM, 如果…...

一些关于单链表的操作

思维导图&#xff1a; 一&#xff0c; 链表 1.1节点的结构 链表是啥样的啊&#xff1f;顾名思义链表就是一种用链子链接起来的表。那这种表是怎么样的啊&#xff1f; 这样的呗&#xff1a; 现在&#xff0c;我们知道了链表的形状了。那我们该如何用编程语言来形成这一种形状…...

CTF-PHP反序列化漏洞2-利用魔法函数

作者&#xff1a;Eason_LYC 悲观者预言失败&#xff0c;十言九中。 乐观者创造奇迹&#xff0c;一次即可。 一个人的价值&#xff0c;在于他所拥有的。可以不学无术&#xff0c;但不能一无所有&#xff01; 技术领域&#xff1a;WEB安全、网络攻防 关注WEB安全、网络攻防。我的…...

Doris(23):Doris的函数—字符串函数

1 append_trailing_char_if_absent(VARCHAR str, VARCHAR trailing_char) 如果s字符串非空并且末尾不包含c字符,则将c字符附加到末尾。 trailing_char只包含一个字符,如果包含多个字符,将返回NULL select append_trailing_char_if_absent(a,c);select append_trailing_cha…...

01-Shiro550漏洞流程

1. 漏洞原理 Apache Shiro框架提供了记住密码的功能&#xff08;RememberMe&#xff09;&#xff0c;用户登录成功后会生成经过加密并编码的cookie。在服务端对rememberMe的cookie值&#xff0c;先base64解码然后AES解密再反序列化&#xff0c;就导致了反序列化RCE漏洞。 那么…...

《程序员面试金典(第6版)》面试题 16.08. 整数的英语表示

题目描述 给定一个整数&#xff0c;打印该整数的英文描述。 示例 1: 输入: 123输出: “One Hundred Twenty Three” 示例 2: 输入: 12345输出: “Twelve Thousand Three Hundred Forty Five” 示例 3: 输入: 1234567输出: “One Million Two Hundred Thirty Four Thousand…...

ChatGPT技术原理 第四章:Transformer模型

目录 4.1 什么是Transformer 4.2 Transformer结构详解 4.3 Self-Attention机制 4.4 Multi-Head Attention机制 4.1 什么是Transformer...

WP Pinch:通过MCP协议为WordPress站点集成AI助手管理能力

1. 项目概述&#xff1a;当你的WordPress站点“长出”AI的爪子 如果你和我一样&#xff0c;每天大部分时间都泡在Slack、Telegram或者WhatsApp里&#xff0c;和团队沟通、处理信息&#xff0c;那么你肯定也烦透了那种“这个内容不错&#xff0c;等我回到电脑前再发到网站上”的…...

模函数激活:挑战ReLU的极致简洁方案,为CV与TinyML带来性能突破

1. 项目概述&#xff1a;为什么我们需要重新审视激活函数&#xff1f;在深度学习的工具箱里&#xff0c;激活函数可能是最不起眼&#xff0c;却又最不可或缺的部件。它就像神经网络中的“开关”或“阀门”&#xff0c;决定了每个神经元是否被激活&#xff0c;以及激活的程度。长…...

ArcGIS 10.2 保姆级安装与破解教程(含License Manager启动失败解决方案)

ArcGIS 10.2 完整安装指南&#xff1a;从零开始到完美运行 1. 准备工作与环境检查 在开始安装ArcGIS 10.2之前&#xff0c;确保你的系统满足以下基本要求&#xff1a; 操作系统&#xff1a;Windows 7/8/10&#xff08;32位或64位&#xff09;硬件配置&#xff1a;至少4GB RAM&a…...

NHSE:5分钟掌握动物森友会存档编辑,打造你的完美岛屿

NHSE&#xff1a;5分钟掌握动物森友会存档编辑&#xff0c;打造你的完美岛屿 【免费下载链接】NHSE Animal Crossing: New Horizons save editor 项目地址: https://gitcode.com/gh_mirrors/nh/NHSE 你是否曾经为了收集某个稀有家具而花费数周时间&#xff1f;是否因为地…...

构建个人AI记忆体:向量数据库与语义搜索实践指南

1. 项目概述&#xff1a;构建你的个人AI记忆体最近几年&#xff0c;AI助手越来越聪明&#xff0c;但总感觉它们“记性”不太好。你昨天刚和它聊过你家的猫叫“橘子”&#xff0c;今天再问它&#xff0c;它可能就忘了。或者&#xff0c;你让它帮你总结上周的工作周报&#xff0c…...

企业组网实战:用爱快+水星AC打造跨地域无线网络,远程管理分支AP就这么简单

企业级无线组网实战&#xff1a;跨地域统一管理与远程控制方案 在数字化转型浪潮中&#xff0c;中小企业对无线网络的依赖程度越来越高。无论是总部办公室、分支机构还是临时办公点&#xff0c;稳定、安全且易于管理的无线网络已成为企业高效运营的基础设施。然而&#xff0c;…...

ThunderAI:开源本地AI助手桌面应用部署与核心架构解析

1. 项目概述&#xff1a;一个开源的AI助手桌面应用 最近在GitHub上闲逛&#xff0c;发现了一个挺有意思的项目&#xff0c;叫“ThunderAI”。这名字听起来就挺带劲&#xff0c;对吧&#xff1f;点进去一看&#xff0c;是个用Python写的桌面应用程序&#xff0c;核心功能是把几个…...

SIGTRAN协议:电信网络IP化的关键技术解析

1. SIGTRAN&#xff1a;下一代电信网络的信令传输基石2003年全球电信业寒冬中&#xff0c;一个技术决策正在悄然改变行业格局。当运营商们紧缩资本开支时&#xff0c;AT&T、Verizon等巨头却不约而同地加大了对IP网络的投入。这背后隐藏着一个关键技术转折——传统TDM网络向…...

Keep架构深度解析:企业级AIOps告警管理平台的设计与实践

Keep架构深度解析&#xff1a;企业级AIOps告警管理平台的设计与实践 【免费下载链接】keep The open-source AIOps and alert management platform 项目地址: https://gitcode.com/GitHub_Trending/kee/keep Keep作为开源AIOps告警管理平台&#xff0c;采用现代化的微服…...

5个Zutilo技巧让你成为Zotero文献管理高手

5个Zutilo技巧让你成为Zotero文献管理高手 【免费下载链接】Zutilo Zotero plugin providing some additional editing features 项目地址: https://gitcode.com/gh_mirrors/zu/Zutilo 还在为Zotero的批量操作烦恼吗&#xff1f;每天面对成百上千的文献条目&#xff0c;…...