剑指Offer(45)-[Array&String]数组中出现次数超过一半的数字

企业数字化转型AI大模型赋能智能体平台及AI场景应用规划方案(生态合作版).pptx 立即下载

点击查看剑指Offer全解【Java & Golang】实现

题目描述

输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。


思路

第一种思路是先将数组排序,然后取中间的那个数字即为出现超过一半的数字。

第二种思路很巧妙,即利用快速排序的partition()函数去确定定位到数组中间的位置,每次使用partition函数获取到的index,即说明该index的左边都是小于array[index]的,右边都是大于array[index]的,它能够通过不完全不完全排序这个性质去解决诸如寻找第k小的数字/第K大的数字这一类问题。

Java第二种思路实现

public class Solution {
    public int MoreThanHalfNum_Solution(int [] array) {
        if (array.length == 0) {
            return 0;
        }
         if (array.length == 1) {
            return array[0];
         }
        int left = 0, right = array.length - 1, mid = left + (right - left)/2;
        int index = partition(array, left, right);
        while (index != mid) {
            if (index < mid) {
                // 需要在index的右边继续寻找
                index = partition(array, index + 1, right);
            } else {
                // 需要在index的左边继续寻找
                index = partition(array, left, index - 1);
            }
        }
        // 确定该数字出现是否超过了一半[若该数字出现超过半数,那么该数左边和右边都应该和它相等]
        if (array[index - 1] != array[index] || array[index] != array[index + 1]) {
            return 0;
        }
        return array[index];
    }
    private int partition(int[] array, int left, int right) {
        // 选取base
        int base = array[left];
        int i = left, j = right;
        while (i < j) {
            while (i < j && array[j] >= base) {
                j--;
            }
            while (i < j && array[i] <= base) {
                i++;
            }
            // 交换i, j
            swap(array, i, j);
        }
        // i, j相重合
        swap(array, left, i);
        return i;
    }
    private void swap(int[] array, int i, int j) {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}
MCGS的Http协议驱动,支持http协议 硬件配置 参数设置 设备属性 设备命令 通讯状态 附录 #HTTP 1、 设备简介 驱动类型 该驱动为独立设备,直接添加构件即可,不需要挂载到父设备下 通讯协议 采用标准HTTP1.1协议 通讯方式 驱动构件为客户端。 2、 硬件连接 本软件在通讯之前,请保证通讯连接正确。通讯连接方式:采用标准的RJ45接口的以太网接线(对调网线或使用HUB交换)。 3、 设备通讯参数 本设备为独立设备,无父设备参数 4、 设备构件参数设置 “HTTP设备”参数设置如下: <1> 内部属性: 构建url信息。 <2> 最小采集周期:本软件对设备进行操作的时间周期,单位为ms,默认为100ms。 <3> 通讯等待时间:通讯数据接收等待时间,默认设置为200ms,当采集速度要求较高或数据量较大时,设置值可适当减小或增大。 <4> HttpHead:http head添加需要的字段,不需要添加http head时值为空,默认不添加。 5、 设备命令 本设备构件提供设备命令,用于进行相应的操作,设备命令的格式如下: 设备命令 命令介绍 GetHttpHead 格式1 GetHttpHead(headStr) 用途 获取http head参数 参数 headStr 参数可以为字符型变量、字符串常量 例1 !SetDevice(设备0,6,"GetHttpHead(headStr)") 获取http head数据保存到headStr中 SetHttpHead 格式1 SetHttpHead(headStr) 用途 设置http head参数 参数 headStr 参数可以为字符型变量、字符串常量 立即下载

相关推荐

【深度解析】信息素养提升实践活动(附:历年获奖作品分析)

全国师生信息素养提升实践活动是由教育部教育技术与资源发展中心(中央电化教育馆)主办,面向全国师生的一项信息化交流展示活动。

m0_74417957的博客 9655

数据结构与算法-- 数组中出现次数超过一半的数字(时间复杂度的讨论)

时间效率 互联网想对时间效率格外的敏感,所以我们总是在需求迭代一定程度后去做优化。而且我们解决问题的时候,时间效率往往是一个考查的重点。因此我们平时编码过程中就必须不断的优化效率,追求完美的态度与能力。 首先是编码习惯,例如java中字符串操作我们不建议使用String的+ 运算符来完成。这样会产生非常多的String临时变量,造成空间与实际的浪费,更好的方式是用StringBuilder的Append方法完成字符串的拼接。 其次,即使是同一个算法用循环和递归两种思路实现时间效率也是不一样的。递归的本质

0102的博客 476

时序基础模型Timer-S1:十亿参数如何革新时间序列预测

时间序列预测是数据分析与机器学习中的核心任务,旨在基于历史数据预测未来趋势。其原理在于捕捉数据中的趋势、周期性和季节性等时序依赖关系。这项技术的价值在于赋能业务决策,广泛应用于金融风控、能源管理、物联网监控和供应链优化等关键场景。传统方法依赖针对特定任务的专用模型,面临泛化能力弱和开发成本高的挑战。本文聚焦的时序基础模型,通过在海量跨领域数据上进行预训练,学习时序通用模式,并结合十亿级参数带来的强大容量,实现了性能的显著突破。这种范式转变,使得模型能够像“全科医生”一样,通过少量数据微调即可快速适应新任务,

weixin_29164843的博客 272

剑指Offer(58)-[Array&String]剪绳子

点击查看剑指Offer全解【Java & Golang】实现 题目描述 给你一根长度为n的绳子,请把绳子剪成m段(m、n都是整数,n>1并且m>1),每段绳子的长度记为k[0],k[1],…,k[m]。请问k[0]xk[1]x…xk[m]可能的最大乘积是多少?例如,当绳子的长度是8时,我们把它剪成长度分别为2、3、3的三段,此时得到的最大乘积是18。 思路 当绳子为2m和3m...

BoringError的博客 393

433MHz无线通信避坑指南:如何解决信号干扰和误码问题

本文深入探讨433MHz无线通信中的信号干扰和误码问题,提供从射频前端设计到协议优化的全链路解决方案。通过天线匹配、电源噪声抑制、曼彻斯特编码改进及实时频点切换等技术,显著提升通信稳定性和距离。适合智能家居和工业无线控制系统的开发者参考。

weixin_29288313的博客 423

Autodesk Genuine Service卸载失败?试试这个隐藏文件删除法(Win8-Win11通用)

本文针对Autodesk Genuine Service在Windows系统(Win8-Win11)中卸载失败的常见难题,提供了深度解析与根治方案。核心方法是手动定位并删除两个关键的隐藏文件(ProductInformation.pit和id.dat),以解除文件锁定或数据损坏导致的卸载障碍,随后再通过标准流程即可成功卸载。该方法通用性强,能有效解决这一困扰设计师和工程师的顽固问题。

weixin_29220405的博客 1483

剑指Offer(44)-[Array&String]字符串的排列

点击查看剑指Offer全解【Java & Golang】实现 题目描述 输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。 思路 使用回溯搜索即可。 Java实现 import java.util.ArrayList; public class Solution {...

BoringError的博客 423

Opencv4.5.1 微信二维码识别功能 QRCode 编译与使用 C++

部分参考:https://mp.weixin.qq.com/s/2GZAJAUPHTXFOKDRv-D21Q 一、下载源码 https://github.com/opencv 二、源码编译 ① 在cmake中添加源码编译路径和生成路径,第一次点击configure。 ② 添加contrib路径 第一次configure后,找到OPENCV_EXTRA_MODULES_PATH,将contrib路径添加进来,注意要具体到modules/,继续configure。 ..

zaibeijixing的专栏 1万+

剑指Offer(48)-[Array&String]替换空格

点击查看剑指Offer全解【Java & Golang】实现 题目描述 请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 思路 第一种思路是直接使用系统的内置字符串处理库去替换掉所有的空格,但是这种方法一般是取巧方法,所以除非真的做不出来,否则不能使用。 第二种思路是先统计空格的...

BoringError的博客 9562

Oracle19c SYSAUX表空间爆满?手把手教你清理SM/ADVISOR和AUDSYS占用(附完整SQL)

本文详细解析了Oracle19c中SYSAUX表空间爆满的常见原因及解决方案,重点针对SM/ADVISOR和AUDSYS组件的空间占用问题提供了完整的SQL清理脚本。通过诊断查询、空间清理和预防性维护策略,帮助DBA有效管理SYSAUX表空间,确保数据库稳定运行。

weixin_28338005的博客 243

从零到一:NI USB-8506 LIN通讯的驱动安装与硬件调试全攻略

本文详细介绍了NI USB-8506 LIN通讯设备的驱动安装与硬件调试全流程,包括硬件准备、驱动下载与配置、NI MAX设置及常见问题解决方案。通过实战应用与性能优化技巧,帮助用户快速掌握LIN通讯技术,适用于车载数据记录和自动化测试等场景。

weixin_28273593的博客 927

【吐血整理】LeetCode与剑指Offer百道经典题解总结

本文整理了LeetCode与剑指Offer中百余道经典的题目,整理出了数组、字符串、链表、二叉树、栈、回溯、动态规划、位运算中的经典问题以及问题对应的链接地址和个人提供的题解,方便查阅以及练习。以下是百题的索引,点击即可找到题目的出处并练习,也可直接查阅答案。 建议刚开始刷题的朋友直接按一下的Tag分类一个专题一个专题地进行学习与作答,完全理解这一百题,一线大厂非你莫属。

BoringError的博客 3900

API深度集成——OpenClaw与第三方服务无缝对接(2026实战版)

本文介绍了OpenClaw系统与第三方服务的API深度集成技术,重点阐述了RESTful API的实现方案。通过一个功能完善的REST客户端类(RestClient)展示了核心功能:支持请求重试、拦截器机制、错误处理和认证管理等;同时提供了API资源管理器(ApiResourceManager)简化资源操作。这些技术实现了OpenClaw与外部系统的稳定可靠对接,为开发者构建API集成方案提供了2026年的最佳实践。

博客 1217

LeetCode(5)-链表:其他问题

LeetCode 148.排序链表 在O(nlogn) 时间复杂度和常数级空间复杂度下,对链表进行排序。 示例 1: 输入: 4->2->1->3 输出: 1->2->3->4 示例 2: 输入: -1->5->3->4->0 输出: -1->0->3->4->5 来源:力扣(LeetCode) ...

BoringError的博客 1128

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

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

LeetCode(2)-栈:单调栈结构

文章目录 一、LeetCode 739. 每日温度 二、LeetCode 496. 下一个更大元素 I 三、LeetCode 503. 下一个更大元素 II 本文是LeetCode刷题总结第二篇,主要总结关于单调栈的题型。单调栈是一种基于栈的数据结构,它是一种有序的栈;它一般用来解决譬如“下一个更大/更小元素”,“当前元素和下一个更大/更小元素间隔多少”,且题目一般会要求...

BoringError的博客 1101

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

LeetCode(4)-链表:快慢指针

文章目录 LeetCode 876.链表的中间节点 LeetCode 19. 删除链表的倒数第N个节点 LeetCode 141. 环形链表 链表中有一个很常用的技巧被称为快慢指针技巧,通常用于找到中间节点和用于解决一些具有环状链表性质的问题 LeetCode 876.链表的中间节点 给定一个带有头结点 head 的非空单链表,返回链表的中间结点。...

BoringError的博客 893

LeetCode(1)-栈:符号匹配类问题

文章目录 一、LeetCode 20.有效的括号 二、LeetCode 844. 比较含退格的字符串 三、LeetCode 682. 棒球比赛 四、LeetCode 921. 使括号有效的最少添加 五、LeetCode 1021. 删除最外层的括号 六、LeetCode 1047. 删除字符串中的所有相邻重复项 本文是LeetCode刷题总结第一篇之栈的...

BoringError的博客 883

LeetCode(6)-树:递归问题

一、递归 二、LeetCode相关题目 2.1、LeetCode 226. 翻转二叉树 2.2、LeetCode 104. 二叉树的最大深度 2.3、LeetCode 112. 路径总和 2.4、LeetCode 111. 二叉树的最小深度 二叉树和多叉树是一种天然的递归结构,每一个节点下的左子树或右子树(针对二叉...

BoringError的博客 839

LeetCode(7)-树:DFS/BFS类问题

文章目录1. LeetCode 144. 二叉树的前序遍历2. LeetCode 589. N叉树的前序遍历3. LeetCode 94. 二叉树的中序遍历4. LeetCode 145.二叉树的后序遍历5. LeetCode 590. N叉树的后序遍历6. LeetCode 102. 二叉树的层次遍历7. LeetCode 102. N叉树的层序遍历8. LeetCode 102. N叉树的层序...

BoringError的博客 763

剑指Offer(19)-[LinkedList] 合并两个排序的链表

点击查看剑指Offer全解【Java & Golang】实现 题目描述 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。 思路 其实这就是链表的归并排序中的“合并”部分: [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wLB6HLu9-1573886800546)(http://note.youdao.com/y...

BoringError的博客 757

剑指Offer(52)-[Array&String]丑数

点击查看剑指Offer全解【Java & Golang】实现 题目描述 把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。 思路 转载自牛客网评论区大佬的思路: 链接:https://www.nowcoder.com/questionTerminal/6aa...

BoringError的博客 685

LeetCode(8)-回溯:组合排列问题

文章目录1.1 LeetCode 46.全排列1.2 LeetCode 47. 全排列 II1.3 LeetCode 77. 组合 今天来总结下LeetCode上关于回溯的应用之排列组合相关的问题 - ( ゜- ゜)つロ 1.1 LeetCode 46.全排列 给定一个没有重复数字的序列,返回其所有可能的全排列。 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,...

BoringError的博客 598

剑指Offer(30)-[HashTable]只出现一次的字符

点击查看剑指Offer全解【Java & Golang】实现 题目描述 在一个字符串(0<=字符串长度<=10000,全部由字母组成)中找到第一个只出现一次的字符,并返回它的位置, 如果没有则返回 -1(需要区分大小写). 思路 创建一个哈希表,在遍历字符串的过程中将当前字符出现的次数存储在哈希表中,第一次出现是1,之后出现N次都算作1(因为只要求得到第一个出现的字符,而不需...

BoringError的博客 563

LeetCode(3)-链表:反转

反转链表是链表的经典问题,往往思路很清晰,但是实现起来总是会出现一些小问题,这里记下一些经典的反转链表问题 目录 Leetcode 206.反转链表 Leetcode 92.反转链表II Leetcode 206.反转链表 反转一个单链表。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->...

BoringError的博客 541

剑指Offer(23)-[LinkedList]删除链表中的重复节点

点击查看剑指Offer全解【Java & Golang】实现 题目描述 在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 例如,链表1->2->3->3->4->4->5 处理后为 1->2->5 思路 首先添加一个头节点dummy,以方便碰到第一个,第二个节点就相同的情况 设置 pr...

BoringError的博客 535

剑指Offer(51)-[Array&String]把数组排成最小的数

点击查看剑指Offer全解【Java & Golang】实现 题目描述 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。 思路 将数组中的数字连接起来,排成一个最小的数字。将’大数’往后放’小数’往前放,如何定义’大数’和’小数’?比如说有两个数a和b,如果ab...

BoringError的博客 522
上一篇: 剑指Offer(44)-[Array&String]字符串的排列
下一篇: 剑指Offer(46)-[Array&String]正则表达式匹配
BoringRong
BoringRong 领域专家: 后端开发技术领域 领域专家: 后端开发技术领域
博客等级 码龄9年 2万+粉丝 386原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

BoringRong

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

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

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

打赏作者

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

抵扣说明:

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

余额充值