华为OD机试 Python 【人数最多的站点】

题目

一个公园里的小火车,它从1号站开到最后一个站,然后又回到1号站,这样循环。员工可以在任意站点上车并在后续的站点下车。我们想知道在这趟车行程中,哪一个站点有最多的员工在车上?

输入:

第一行告诉我们有多少员工参与调查。
接下来的每一行,都是两个数字。第一个数字是员工上车的站点,第二个数字是他们下车的站点。
输出:

输出一个站点编号,表示车上人数最多的站点。若存在多个站点人数相同,输出编号最小的站点。
示例:

输入:
3
1 3
2 4
1 4

输出:
2

代码

def max_occupied_station(n, rides):
    # 每个站点的乘客数,初始为0
    station_passengers = 
【华为OD机试真题 Python语言】198、人数最多的站点/小火车最多人时所在园区站点 | 机试真题+思路参考+代码分析 公园园区提供小火车单向通行,从园区站点编号最小到最大,通行如1~ 2 ~ 3 ~ 4~1,然后供员工在各个办公园区穿梭,通过对公司N个员工调研统计到每个员工的坐车区间,包含前后站点,请设计一个程序计算出小火车在哪个园区站点时人数最多 阅读详情

相关推荐

华为OD机试真题Python实现【人数最多的站点】真题+解题思路+代码(2022&2023)

为原创内容,该部分版权由 OD 联盟共同拥有,并授权组内成员发布。为原创内容,该部分版权由 OD 联盟共同拥有,并授权组内成员发布。人数最多时的园区站点编号,最多人数相同时返回编号最小的园区站点。本题目的目标是统计一组数据中,哪一个数字出现最多的次数。公园园区提供小火车单向通行,从园区站点编号最小到最大,个员工调研统计到每个员工的坐车区间,包含前后站点,万,然后供员工在各个办公园区穿梭,使用数字代替每个园区用空格,分割如。返回数字最小的园区,所以输出。👉 助你解开所有机试题。个行,为调研员工人数。

码莎拉蒂 1438

华为OD机试 - 人数最多的站点(JAVA、C、C++、GO、Python、JavaScript)

华为OD机试题 人数最多的站点,JAVA & Python & C & C++ & GO & JavaScript

一直在水些技术小文 447

华为OD机试A卷 - 人数最多的站点 (C++ & Python & JAVA & JS & GO)

华为OD机试A卷 人数最多的站点,提供Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解。

qq_45776114的博客 231

华为OD机试 - 人数最多的站点(Python)| 真题+思路+考点+代码+岗位

公园园区提供小火车单向通行,从园区站点编号最小到最大,通行如1~2~3~4~1万,然后供员工在各个办公园区穿梭,通过对公司N个员工调研统计到每个员工的坐车区间,包含前后站点,请设计一个程序计算出小火车在哪个园区站点时人数最多。

坚果的博客 408

深度解析华为OD机试题目:人数最多的小火车园区站点问题与解题思路(适用于Java、C++、Python、JavaScript)

通过本篇文章,我们深入剖析了华为OD机试中的一道常见题目“人数最多的小火车园区站点”。该题考查了程序员对于区间重叠问题的理解与处理能力。本文不仅给出了详细的题目解析和解题思路,还分别用Java、C++、Python、JavaScript四种语言实现了解决方案。希望这篇文章能帮助到在准备华为OD机试的你,提高对算法题目的理解和解题能力。

m0_57781768的博客 257

华为OD机试A卷 - 人数最多的站点/小火车最多人时所在园区站点(C++ Java JavaScript Python )

1,然后供员工在各个办公园区穿梭,通过对公司N个员工调研统计到每个员工的坐车区间,包含前后站点,请设计一个程序计算出小火车在哪个园区站点时人数最多。使用数字代替每个园区用空格分割,如3 5表示从第3个园区上车,在第5个园区下车。人数最多时的园区站点编号,最多人数相同时返回编号最小的园区站点。公园园区提供小火车单向通行,从园区站点编号最小到最大通行如1。即,找到具有最大重叠部分的区间的起点就是本题题解。第2行开始,为每个员工的上车站点和下车站点。本题是求解最大重叠区间个数的变种题。第1个行,为调研员工人数。

算法大师! 154

【华为OD机试真题】198、人数最多的站点/小火车最多人时所在园区站点 | 机试真题+思路参考+代码分析(C语言、C++、Java、Py、JS)

公园园区提供小火车单向通行,从园区站点编号最小到最大,通行如1~ 2 ~ 3 ~ 4~1,然后供员工在各个办公园区穿梭,通过对公司N个员工调研统计到每个员工的坐车区间,包含前后站点,请设计一个程序计算出小火车在哪个园区站点时人数最多

KJ.JK 1129

华为OD机试 - 人数最多的站点(Python/JS/C/C++ 2024 E卷 100分)

刷的越多,抽中的概率越大,私信哪吒,备注华为OD,加入华为OD刷题交流群,每一题都有详细的答题思路、详细的代码注释、发现新题目,随时更新,全天优快云在线答疑。

学Java,找哪吒 1304

【华为OD机试】人数最多的站点/小火车最多人时所在园区站点(C++/Java/Python)

【华为OD机试】人数最多的站点/小火车最多人时所在园区站点(C++/Java/Python)

dvlinker的技术专栏 154

华为OD机试2023(JS,C++,JAVA,PYTHON)-人数最多的站点--小火车最多人时所在园区站点

公园园区提供小火车单向通行,从园区站点编号最小到最大通行如12341,然后供员工在各个办公园区穿梭,通过对公司N个员工调研统计到每个员工的坐车区间,包含前后站点,请设计一个程序计算出小火车在哪个园区站点时人数最多。

qznjj6的博客 211

【华为OD机试真题 2025B卷】664、人数最多的站点/小火车最多人时所在园区站点 | 机试真题+思路参考+代码解析(C++、Java、Py)(B卷复用)

【华为OD机试真题 2025B卷】664、人数最多的站点/小火车最多人时所在园区站点 | 机试真题+思路参考+代码解析(C++、Java、Py)(B卷复用) 华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2024e卷,od机试,2024E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2

KJ.JK 2133

华为OD机试 - 小火车最多人时所在园区站点(Python/JS/C/C++ 2024 E卷 100分)

刷的越多,抽中的概率越大,私信哪吒,备注华为OD,加入华为OD刷题交流群,每一题都有详细的答题思路、详细的代码注释、发现新题目,随时更新,全天优快云在线答疑。

学Java,找哪吒 1134

【华为OD机试真题 2025C卷】198、农场施肥、不爱施肥的小布 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS)

【华为OD机试真题 2025C卷】198、农场施肥、不爱施肥的小布 | 机试真题+思路参考+代码解析(C++、Java、Py、C语言、JS) 华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2025e卷,od机试,2025E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2025华为od,

正在更新最新华为OD机试2025B卷,提供OJ在线刷题 1001

PyCharm与MicroPython联手:打造高效ESP32开发环境

本文详细介绍了如何使用PyCharm与MicroPython打造高效的ESP32开发环境。通过配置PyCharm插件、刷写MicroPython固件以及实战示例,帮助开发者快速上手嵌入式Python开发,显著提升物联网项目的开发效率。

weixin_29169899的博客 384

自动驾驶系统研发系列—全智能驾驶新高度:深入解析车道保持辅助(ELK)功能

车道保持辅助系统(ELK)是一种基于先进视觉感知技术的主动安全系统,能够通过车载摄像头实时监测道路上的车道线、道路边缘以及周围车辆的位置。这一功能的核心在于为驾驶员提供智能化的安全辅助,尤其是在驾驶员可能因疲劳、分心或其他原因无意识地偏离车道时,系统能够主动干预,从而避免危险发生。ELK系统不仅仅依靠摄像头对道路进行感知,还结合其他传感器的数据(如雷达),实时评估自车与车道线、周边车辆的相对位置。当系统检测到车辆即将偏离车道,或越过道路边缘时,ELK会通过控制电子助力转向系统(EPS)

u013889591的专栏 1211

[CSP-X2025山东小学组T4]勇者斗恶龙

[CSP-X2025山东小学组T4]勇者斗恶龙,动态规划

少儿编程乔老师 150

YOLOV5 自动刷图脚本实战(十五)之如何找到正确的门

DXF是一个2D游戏,我们所看到的人物移动,其实是后面的背景在移动,我们所看到的画面,不过是一个完整背景中的一个镜头视角而已想要正确找到门的坐标,我们需要对不同的地图中的每个房间做一些配置信息。

qq_38892949的博客 2813

【城市数据集】世界城市数据库和访问门户工具WUDAPT

简介世界城市数据库和访问门户工具WUDAPT

WW、forever的博客 1286

点云目标检测:open3d多窗口联动可视化

多个模型之间的对比除了指标之外,还需要可以直接直观的对比可视化结果,这次介绍一下如何使用open3d同时打开两个窗口分别加载两个模型的结果进行对比,同时实现两个窗口的联动,也就是当一个窗口拖动或者缩放时另外一个窗口也跟着做同样的变换。

zhaoguanhua的博客 4688

PPT制作能力在职场中真的重要吗?一定要美术功底才能学好PPT吗?

我推出PPT技能培训专栏啦!好的PPT可以让你事半功倍、2023拥有PPT能力还可以让你具备一门极有价值的斜杠能力。更多内容请进:梦幻训练营专栏。专栏内会用本人积累的近10年的PPT学习方法论在短时间内教会你如何制作出精美绝伦的PPT,每篇教程后还会免费赠送一些小福利,不可多得。

打造全国最全的AI Agent开发知识领域的博客 729

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

上一篇: 华为OD机试 Python 数字比大小
下一篇: 华为OD机试 Python 称砝码
AlgorithmHero
博客等级 码龄4年 606粉丝 1067原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AlgorithmHero

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值