【100%通过率 】【华为OD机试真题c++ /python】寻找符合要求的最长子串【 2022 Q4 A卷 |200分】

【华为OD机试】-真题 !!点这里!!

【华为OD机试】真题考点分类 !!点这里 !!

知识点双指针

时间限制:1s 空间限制:256MB 限定语言:不限

题目描述:

给定一个字符串 s ,找出这样一个子串:

1)该子串中的任意一个字符最多出现2次;

2)该子串不包含指定某个字符;

 请你找出满足该条件的最长子串的长度。

输入

第一行为不包含的指定字符,为单个字符[0-9a-zA-Z]

第二行为字符串s

输出

一个整数,满足条件的最长子串长度。

如不存在满足条件的子串,则返回0。

示例1

输入

D

<
AutoGPT:面向生产环境的AI智能体自动化操作系统 AI智能体(Agent)是大语言模型从对话工具迈向自主执行的关键演进,其核心在于构建有状态、可编排、可监控的闭环运行机制。不同于无状态API调用,智能体需持续维护任务队列、记忆缓存与工具调用历史,依赖平台化架构实现故障隔离、资源调度与协议标准化。AutoGPT正是这一范式的工程落地代表——它以Python+TypeScript双栈支撑AI逻辑与交互体验,通过Docker容器化与agent_protocol协议分层,提供开箱即用的Agent生命周期管理能力。在跨境电商、竞品监控、工业PLC控制等真实场景中,已 阅读详情

相关推荐

【满分】【华为OD机试真题2023C&D卷 JAVA&JS】求满足条件的最长子串的长度

给定一个字符串,只包含字母和数字,按要求找出字符串中的最长(连续)子串的长度,字符串本身是其最长的子串,子串要求:1、 只包含1个字母(a~z, A~Z),其余必须是数字; 2、 字母可以在子串中的任意位置;

qq_34465338的博客 2860

【华为OD机试 c++】采样过滤【 2022 Q4考试题 A卷 |200分】

在做物理实验时,为了计算物体移动的速率,通过相机等工具周期性的采样物体移动距离。 由于工具故障,采样数据存在误差甚至错误的情况。 需要通过一个算法过滤掉不正确的采样值,不同工具的故障模式存在差异,算法的相关门 限会根据工具类型做相应的调整。 请实现一个算法,计算出给定一组采样值中正常值的最长连续周期。 判断第i个周期的采样数据Si是否正确的规则如下(假定物体移动速率不超过10个单元前一个 采样周期S[i-1]):

goldarmour的博客 1803

华为od机试真题 C++ 实现【符合要求的结对方式】

用一个数组A代表程序员的工作能力,公司想通过结对编程的方式提高员工的能力,假设结对后的能力为两个员工的能力之和,求一共有多少种结对方式使结对后能力为N。

MISAYAONE的博客 1011

2026华为OD机试(Python)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,Python实现。

MISAYAONE的博客 29万+

2026华为OD机试(C语言)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,C语言实现。

MISAYAONE的博客 11万+

2026华为OD机试(C++)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,C++实现。

MISAYAONE的博客 20万+

2026华为OD机试(JavaScript)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,JavaScript实现。

MISAYAONE的博客 8万+

2026华为OD机试(JAVA&Go)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,Java实现。

MISAYAONE的博客 34万+

华为OD机试 新系统 双机位C卷 往年真题 机考题库(持续收录中)以及算法考点详解(Python/JS/C/C++)

刷的越多,抽中的概率越大,每一题都有详细的答题思路、详细的代码注释发现新题目,随时更新。

学Java,找哪吒 5万+

华为OD机试-投篮大赛-2022Q4 A卷-Py/Java/JS

华为OD机试-投篮大赛-2022Q4 A卷-Py/Java/JS

miao_9的博客 716

【满分】【华为OD机试真题2023 JAVA&JS】寻找符合要求的最长子串

寻找符合要求的最长子串 题目描述:给定一个字符串 s ,找出这样一个子串:1)该子串中的任意一个字符最多出现2次;2)该子串不包含指定某个字符;请你找出满足该条件的最长子串的长度。

qq_34465338的博客 3606

【华为OD机试c++】优选核酸检测点【2022 Q4 A卷|200分】

张三要去外地出差,需要做核酸,需要在指定时间点前做完核酸,请帮他找到满足条件的核酸检测点。• 给出一组核酸检测点的距离和每个核酸检测点当前的人数• 给出张三要去做核酸的出发时间出发时间是10分钟的倍数同时给出张三做核酸的最晚结束时间• 题目中给出的距离是整数,单位是公里,时间1分钟为一基本单位

goldarmour的博客 1138

2024华为OD机试真题-箱子之字形摆放(C++/Java/Python)-E卷A卷-100分

有一批箱子(形式为字符串,设为str),要求将这批箱子按从上到下以之字形的顺序摆放在宽度为 n 的空地,请输出箱子的摆放位置。例如:箱子ABCDEFG,空地宽度为3,摆放结果如图:输入一行字符串,通过空格分隔,前面部分为字母或数字组成的字符串str,表示箱子;后面部分为数字n,表示空地的宽度。例如:

goldarmour的博客 1695

R语言安装包镜像报错?5分钟教你快速切换国内镜像源(含清华/阿里云配置)

本文详细介绍了R语言安装包镜像报错的解决方案,包括如何快速切换国内镜像源(如清华、阿里云等),解决'无法读写貯藏處索引'等常见问题。通过图形界面和命令行两种方式,帮助用户高效配置镜像源,提升R语言包安装速度与稳定性。

weixin_29053073的博客 423

非线性动力学_用MatCont分析非线性动力学方程组(一)

写在前面:笔者打算写两到三篇系列文章介绍MatCont,此为第一篇《用MatCont分析非线性动力学方程组(一)》。MatCont是一个基于Matlab而开发的免费工具包,专门用来做非线性动力学模型分叉、向量场、周期性等分析,符号(连续性)运算和数值(离散性)运算均适用。该工具的开发及研究项目由比利时Ghent大学的Willy Govaerts教授、荷兰Utrecht大学的Yuri Kuznets...

weixin_39700215的博客 2773

Infiniband互连网络概述

一、Infiniband是什么? InfiniBand(简称IB)是一种工业标准规范,它定义了一种输入/输出架构,用于计算节点、通信基础设施设备、存储和嵌入式系统的互连。操作系统可以是Linux、Windows或ESXI。 IB网络一共是五层,从第一天起,IB就被设计为提供一个端到端的解决方案,改善和加速从物理层到上层的所有协议层。 IB协议于2000年由IBTA(InfiniBand Trade Association)提出,其规定了一...

weixin_41687819的博客 5231

Amos实战:如何用Bootstrap法检验中介效应?附完整操作步骤

本文详细介绍了如何使用Amos软件通过Bootstrap法检验中介效应,包括模型设定、参数配置和结果解读。Bootstrap方法因其不依赖正态分布假设、统计功效高等优势,成为中介效应分析的首选方法。文章提供了完整的操作步骤和实用建议,帮助研究者准确评估变量间的中介作用机制。

zz67890的博客 1456

DeepSeek+Dify实战:零代码构建智能SQL生成器

本文详细介绍了如何利用DeepSeek和Dify零代码构建智能SQL生成器,帮助非技术人员通过自然语言查询数据库。文章涵盖从数据准备、知识库设计到Agent配置的全流程,并提供了优化技巧和实际应用案例,显著提升团队数据查询效率。

weixin_29311017的博客 422

绿盾用户使用看图软件每次都需要把图片解密之后才能打开查看,怎么才能不用这么麻烦打开就能看

Win10专业版绿盾控制台7.0看图软件FastStone Image Viewer。

本博客,博文仅代表个人操作经验,不能完全解决你的问题,仅供参考,佛系回复。 1204

【DRAM存储器二】Sense Amplifier

详述DRAM颗粒中感应放大器功能、电路结构、工作原理和操作波形

highman110的博客 7217

大模型系列——一文看懂“提示词” vs “提示词工程” vs “上下文工程”

本文区分了AI领域的三个关键概念:提示词(Prompt)、提示词工程(Prompt Engineering)和上下文工程(Context Engineering)。提示词是直接输入给AI模型的指令文本;提示词工程则是系统化设计、测试和优化提示词的过程;而上下文工程是为AI构建动态上下文,提供恰当信息和工具的科学与艺术。文章通过翻译案例展示了提示词工程的迭代过程,并说明上下文工程在AI Agent中的核心作用——动态收集和组织必要信息。最后强调普通人只需掌握提示词编写,开发AI应用才需深入提示词工程,构建智能

2401_84052244的博客 755

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

深度学习工具包 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")

上一篇: 华为OD机试-2023真题-考点分类
下一篇: 【100%通过率】【华为OD机试python实现】通信误码【 2023 Q1 A卷 |100分】
2024剑指offer
博客等级 码龄17年 3043粉丝 768原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

2024剑指offer

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

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

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

打赏作者

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

抵扣说明:

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

余额充值
⌂ 换网址