7.8华为OD机试真题 新系统 - 魔法咒语组合 (Java/Py/C/C++/Js/Go)

魔法咒语组合

2026 华为OD机试真题 7月8日华为OD上机新系统考试真题 100 分题型

点击查看华为 OD 机试真题完整目录:2026最新华为OD机试新系统卷 + 双机位C卷 真题题库目录|全覆盖题库 + 逐点算法考点详解

题目描述

玩家收集了 N 个魔法咒语碎片,它们可以组合成强大的魔法阵。但并不是所有碎片都能使用——只含咒语中没有重复字母的碎片才是纯净的,可以激活。

请找出所有纯净碎片,输出由所有纯净碎片组成的所有魔法阵方案。

备注: 所有魔法咒语碎片互不重复

输入描述

  1. 魔法咒语碎片为一个字符串,仅由小写字母构成,没有分隔符,字符串长度不超过 26。
  2. 魔法咒语碎片数量 N 小于等于 6 个。

输出描述

  1. 魔法阵方案,由所有纯净碎片组成的长字符串,每个纯净碎片的字符串之间以空格隔开(" ")。
  2. 所有魔法阵方案按字母序排列输出。

示例1

输入

fire,water,earth

输出

["earth fire water","earth water fire","fire earth water","fire water earth","water earth fire","water fire earth"]

说明

示例2

输入

noon,sun,sky

输出

["sky sun","sun sky"]

说明

  • “noon”:字母 ‘n’ 重复,不纯净,舍弃
  • “sun”:字母无重复,是纯净的
  • “sky”:字母无重复,是纯净的
  • 可以形成一个 2!=2 的全排列

解题思路

核心思想

筛选出不包含重复字母的"纯净"碎片,然后对这些纯净碎片进行全排列,输出所有可能的魔法阵组合方案。

算法步骤

  1. 过滤纯净碎片:遍历所有碎片,筛选出字符串中所有字母都不重复的碎片
  2. 全排列生成:对纯净碎片列表使用 itertools.permutations 生成所有排列
  3. 格式化输出:将每个排列用空格连接成字符串
  4. 字典序排序:对所有方案按字母序排序后返回

复杂度分析

  • 时间复杂度:O(N! × L),其中 N 为纯净碎片数量,L 为平均字符串长度
  • 空间复杂度:O(N! × L) 用于存储所有排列结果

Java

华为OD机试双机位C卷-魔法收积木 (C/C++/Py/Java/Js/Go) 华为OD机试(机考)双机位C卷 【魔法收积木】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为od - 魔法收积木。 阅读详情

相关推荐

华为OD机试双机位C卷:采购订单 (Py/Java/C/C++/Js/Go)

华为OD机试双机位C卷 采购订单,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,并提供在线OJ模拟做题。华为OD机试真题【采购订单】

qq_45776114的博客 3539

华为OD机试双机位C卷-跳房子 (Py/Java/C/C++/Js/Go)

华为OD机考双机位C卷 - 跳房子(OD上机考试双机位C卷)。提供C语言、Java、C++、Python、GO语言、JavaScript题解,并提供完整思路讲解。并提供在线OJ刷题。华为OD机试 - 跳房子。

qq_45776114的博客 1144

华为OD机试双机位C卷:斗地主之顺子 (C/C++/Py/Java/Js/Go)

华为OD机试双机位C卷 斗地主之顺子,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解。华为OD机试 - 斗地主之顺子。

qq_45776114的博客 1535

华为OD机试双机位C卷 - 关联端口组合并(Py/Java/C++/Js/Go)

华为OD机试双机位C卷 关联端口组合并,提供Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解。华为OD机试 - 关联端口组合并。

qq_45776114的博客 1447

华为OD机试双机位C卷-分月饼(C/C++/Py/Java/Js/Go)

华为OD机试双机位C卷 【分月饼】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解。华为OD机试真题【分月饼】。

qq_45776114的博客 1037

8.26华为OD机试真题 新系统 - 仓库查询 (Java/Py/C/C++/Js/Go)

8.26华为OD机试真题 新系统 - 仓库查询 (Java/Py/C/C++/Js/Go)

算法大师! 1760

华为OD机试双机位C卷-贪吃蛇 (C/C++/Py/Java/Js/GO)

华为OD机试(机考)双机位C卷 【贪吃蛇】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。

qq_45776114的博客 1102

华为OD机试双机位C卷-AI处理器组合 (Py/Java/C/C++/Js/Go)

华为OD机试(机考)双机位C卷 【AI处理器组合】,提供Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。

qq_45776114的博客 1177

华为OD机试真题 新系统 - 配置操作失败数量统计 (Java/Py/C/C++/Js/Go)

华为OD机试真题 新系统 - 配置操作失败数量统计本文整理华为 OD 机试新系统机考真题库,涵盖高频考点精析与完整题目内容,提供 C 语言、Java、C++、Python、Go、JavaScript 多语言源码实现,搭配详细解题思路讲解,并支持在线 OJ 刷题练习,助力高效备考华为 OD 机试新系统。

算法大师! 1937

华为OD机试新系统真题-魔法咒语组合(Java/Py/C++/Go/C/Js)

华为OD机试 新系统真题【魔法咒语组合】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【魔法咒语组合】多语言题解

qq_45776114的博客 676

华为OD机试真题 新系统 - 直捣黄龙 (Java/Py/C/C++/Js/Go)

本文整理华为 OD 机试新系统机考真题库,涵盖高频考点精析与完整题目内容,提供 C 语言、Java、C++、Python、Go、JavaScript 多语言源码实现,搭配详细解题思路讲解,并支持在线 OJ 刷题练习,助力高效备考华为 OD 机试新系统。

算法大师! 1979

华为OD机试双机位C卷-去除多余空格(Py/Java/C/C++/Js/Go)

华为OD机试(机考)双机位C卷 【去除多余空格】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试 - 去除多余空格,华为OD机考 - 去除多余空格

qq_45776114的博客 1340

2026最新华为OD机试新系统机考真题- 真题题库目录|全覆盖题库 + 逐点算法考点详解

2026年4月1日起,华为OD机试正式切换至新系统模式!采用力扣模式,无需自己写输入! 难度大幅度降低。正在备考华为OD机试的同学,优先刷新系统机试真题,可大幅提升通过率。 新系统考题考点与旧版一致,无需重新适应。本专栏所有算法题均配有详细思路解析,并提供C语言、JS、C++、Python、Go、Java多语言源码实现。订阅后私信即可开通专属OJ刷题权限,高效备考一次上岸!

算法大师! 2768

8.30华为OD机试真题 新系统 - 快递驿站计费系统(Java/Py/C/C++/Js/Go)

8.30华为OD机试真题 新系统 - 快递驿站计费系统(Java/Py/C/C++/Js/Go)

算法大师! 1048

华为OD新系统机试真题 - 准备生日礼物(Py/Java/C/C++/Js/Go)

华为OD机试新系统真题 4.8【准备生日礼物】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【准备生日礼物】

qq_45776114的博客 1496

华为OD新系统机试真题 - 直捣黄龙 (C/C++/Py/Java/Js/Go)

华为OD机试新系统真题 【直捣黄龙】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD新系统机试真题【直捣黄龙】。

qq_45776114的博客 1607

9.20华为OD机试真题 新系统 - 递增差排列 (Java/Py/C/C++/Js/Go)

9.20华为OD机试真题 新系统 - 递增差排列 (Java/Py/C/C++/Js/Go)

算法大师! 1084

避开STM32中断优先级配置的坑:HAL_NVIC_SetPriority()参数你真的用对了吗?

本文深入解析STM32中断优先级配置中的关键问题,重点剖析HAL_NVIC_SetPriority()函数的正确使用方法。通过实际案例揭示优先级分组设置、抢占优先级与子优先级的区别,提供多中断系统中的优化策略和调试技巧,帮助开发者避免常见配置错误,提升系统稳定性。

weixin_42532938的博客 425

SPWM波调制度原理

SPWM波调制度原理

qq_43557686的博客 1万+

2.数字芯片时序正确的前提—Max-transition

芯片物理设计中最基本的Max-transition检查

weixin_43868998的博客 5428

J-LINK下载程序出现No Cortex-M Device found in JTAG chain…问题,最全7种解决方法

J-Link下载程序出现No Corect 等的问题的7种方法 后来编辑JLinkSettings.ini文件,找到"Device"项,将其更改Device="Cortex-M0+"

cjmsea的博客 5622

用miniconda建立PyTorch、Keras、TensorFlow三个环境

如果还没有安装Miniconda,请从[Miniconda官网](https://docs.conda.io/en/latest/miniconda.html)下载合适的版本并进行安装。如果遇到问题,可以通过编辑`~/.condarc`文件来临时禁用某个源,或者通过`conda config --remove channels`命令来移除配置的镜像源。要切换到不同的环境,先使用`conda deactivate`命令退出当前环境,再用`conda activate 环境名称`命令激活另一个环境。

数字人生 2464

基于 FPGA Vivado 信号发生器设计(附源工程)

今天给大侠带来基于 FPGA Vivado 信号发生器设计,开发板实现使用的是Digilent basys 3,如有想要入手basys3开发板的,可以联系牛总:18511371833。话不多说,上货。 本篇掌握基于 FPGA Vivado 信号发生器设计(附源工程),掌握基于添加文件和IP的Vivado工程设计流程,掌握基于Tcl的Vivado工程设计流程,学习信号发生器的基本组成结构。获取本篇相关源工程代码,可在公众号内回复“信号发生器设计源工程”。 设计原理 信号发生器...

7993

Python 爬虫高级实战:HTTPS 证书忽略与代理抓包配置

本文深入解析了HTTPS加密与SSL证书校验机制在爬虫开发中的核心问题及解决方案。文章首先剖析了HTTPS协议架构和证书校验流程,指出爬虫开发中常见的证书异常场景及其负面影响。随后详细介绍了Python主流请求库(requests、httpx、aiohttp)的证书忽略配置方法,包括同步/异步模式下的实现方案。针对代理环境,文章系统比较了HTTP、HTTPS、SOCKS5等代理类型的特性差异,并提供了完整的代理配置示例。特别对中间人抓包场景,阐述了Mitmproxy的工作原理和配置要点。最后提出了工程级爬虫

2503_91057718的博客 88

9.20华为OD机试真题 新系统 - 字符串分组求和 (Java/Py/C/C++/Js/Go)

9.20华为OD机试真题 新系统 - 字符串分组求和 (Java/Py/C/C++/Js/Go)

算法大师! 603

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

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

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

上一篇: 7.8华为OD机试真题 新系统 - 计算碳排放减少量 (Java/Py/C/C++/Js/Go)
下一篇: 7.1华为OD机试真题 新系统 - 奇偶三数之和 (Java/Py/C/C++/Js/Go)
算法大师
算法大师 新星创作者: 算法与数据结构技术领域 新星创作者: 算法与数据结构技术领域
博客等级 码龄5年 1万+粉丝 1686原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

算法大师

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

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

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

打赏作者

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

抵扣说明:

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

余额充值