leetcode(46-50)

LeetCode+ 46 - 50 算法标签:数组、回溯给我们一个没有重复数字的数列让我们求它的全排列递归暴搜的实现按照什么顺序来搜索,排列问题有很多种搜索的顺序①我们可以从前往后枚举每一个位置填哪个数,可以先枚举第一个位置填哪个数,再枚举第二个位置填哪个数,以此类推 √②依次枚举每个数放到哪个位置上,第一个数可以放在第 0 个位置上,可以放到第一个位置上也可以放到第二个位置上;第二个数可以放到第 0 个位置上,可以放到第一个位置上也可以放到第二个位置上对于排列问题来说,以上两种搜索顺序都是可以的接下来画一下第一种方案的递归搜索树,每一个叶子 阅读详情

46. 全排列

给定一个没有重复数字的序列,返回其所有可能的全排列。

示例:

输入: [1,2,3]
输出:
[
  [1,2,3],
  [1,3,2],
  [2,1,3],
  [2,3,1],
  [3,1,2],
  [3,2,1]
]
class Solution {
public:
    vector<vector<int>> permute(vector<int>& nums) {
        vector<vector<int>> res;
        dfs(0,nums,res);
        return res;
    }
    void dfs(int cur,vector<int> &nums,vector<vector<int>> &res){
        if(cur == nums.size()-1){
            res.push_back(nums);
            return;
        }
        for(int i=cur;i<nums.size();i++){
            swap(nums[cur], nums[i]);
            dfs(cur+1,nums,res);
            swap(nums[cur], nums[i]);
        }
    }
};

 47. 全排列 II

给定一个可包含重复数字的序列,返回所有不重复的全排列。

示例:

输入: [1,1,2]
输出:
[
  [1,1,2],
  [1,2,1],
  [2,1,1]
]
class Solution {
public:
    vector<vector<int>> permute(vector<int>& nums) {
        vector<vector<int>> res;
        vector<int> tmp;
        vector<bool> index(nums.size(), true);
        sort(nums.begin(),nums.end());
        dfs(res,tmp,nums,index);
        return res;
    }
    
    void dfs(vector<vector<int>> &res, vector<int> &tmp, vector<int> &nums, vector<bool> &index){
        if(tmp.size() == nums.size()){
            res.push_back(tmp);
            return;
        }
        for(int i=0; i<nums.size(); i++){
            if(index[i] == false) continue;
            if(i>0 && nums[i]==nums[i-1] && index[i-1]==true) continue;
            tmp.push_back(nums[i]);
            index[i]=false;
            dfs(res,tmp,nums,index);
            tmp.pop_back();
            index[i]=true;
        }
    }
};

48. 旋转图像

给定一个 n × n 的二维矩阵表示一个图像。

将图像顺时针旋转 90 度。

说明:

你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。

示例 1:

给定 matrix = 
[
  [1,2,3],
  [4,5,6],
  [7,8,9]
],

原地旋转输入矩阵,使其变为:
[
  [7,4,1],
  [8,5,2],
  [9,6,3]
]

示例 2:

给定 matrix =
[
  [ 5, 1, 9,11],
  [ 2, 4, 8,10],
  [13, 3, 6, 7],
  [15,14,12,16]
], 

原地旋转输入矩阵,使其变为:
[
  [15,13, 2, 5],
  [14, 3, 4, 1],
  [12, 6, 8, 9],
  [16, 7,10,11]
]
class Solution {
public:
    void rotate(vector<vector<int>>& matrix) {
        for(int i=0; i<matrix.size(); i++){
            for(int j=i; j<matrix[0].size(); j++){
                swap(matrix[i][j],matrix[j][i]);
            }
        }
        for(int i=0; i<matrix.size(); i++){
            for(int j=0; j<matrix.size()/2; j++){
                swap(matrix[i][j],matrix[i][matrix.size()-1-j]);
            }
        }
    }
};

49. 字母异位词分组

给定一个字符串数组,将字母异位词组合在一起。字母异位词指字母相同,但排列不同的字符串。

示例:

输入: ["eat", "tea", "tan", "ate", "nat", "bat"],
输出:
[
  ["ate","eat","tea"],
  ["nat","tan"],
  ["bat"]
]

说明:

  • 所有输入均为小写字母。
  • 不考虑答案输出的顺序。
class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>> res;
        if(strs.size() <= 0) return res;
        unordered_map<string,vector<string>> hash;
        for(auto str:strs){
            string st=str;
            sort(st.begin(),st.end());
            hash[st].push_back(str);
        }
        for(auto s:hash){
            res.push_back(s.second);
        }
        return res; 
    }
};

50. Pow(x, n)

实现 pow(x, n) ,即计算 x 的 n 次幂函数。

示例 1:

输入: 2.00000, 10
输出: 1024.00000

示例 2:

输入: 2.10000, 3
输出: 9.26100

示例 3:

输入: 2.00000, -2
输出: 0.25000
解释: 2-2 = 1/22 = 1/4 = 0.25

说明:

  • -100.0 < x < 100.0
  • n 是 32 位有符号整数,其数值范围是 [−231, 231 − 1] 。
class Solution {
public:
    double myPow(double x, int n) {
        if(n==0) return 1;
        if(n<0 && n>INT_MIN){
            n=-n;
            x=1/x;
        }
        return (n%2==0) ? pow(x*x, n/2) : x*pow(x*x, n/2);
    }
};

(以上题目均摘自leetcode)

leetcode刷题(46-50) 算法是码农的基本功,也是各个大厂必考察的重点,让我们一起坚持写题吧。遇事不决,可问春风,春风不语,即是本心。我们在我们能力范围内,做好我们该做的事,然后相信一切都事最好的安排就可以啦,慢慢来,会很快,向前走,别回头。 阅读详情

相关推荐

Ubuntu安装opencv4.5(自己安装过程详细)

1.下载opencv 在opencv官网下载source版,下载链接 http://opencv.org/releases.html。别下载错版本 下载过程就不多说了。 2.安装过程 2.1解压 unzip opencv-4.5.0.zip cd opencv-4.5.0 2.2安装依赖的库 sudo apt-get install cmake sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-

weixin_45629790的博客 1万+

【PythonCode】力扣Leetcode46~50题Python版

力扣46-50

weixin_43790276的博客 1652

基于Simulink的直流电机双闭环调速系统抗扰动仿真与参数优化

本文详细介绍了基于Simulink的直流电机双闭环调速系统仿真与参数优化方法。通过构建转速外环与电流内环的仿真模型,阐述了利用工程设计法整定PI参数的核心步骤,并重点探讨了如何优化系统参数以增强其抗负载突变等扰动的能力,实现快速、平稳的调速性能。

weixin_29061997的博客 193

LeetCode 46~50

前言 本文隶属于专栏《LeetCode 刷题汇总》,该专栏为笔者原创,引用请注明来源,不足和错误之处请在评论区帮忙指出,谢谢! 本专栏目录结构请见LeetCode 刷题汇总 正文 幕布 幕布链接 46. 全排列 题解 A general approach to backtracking questions in Java (Subsets, Permutations, Combination Sum, Palindrome Partioning) 回溯 + 11 import scala.collec

Shockang的博客 6126

Qwen3.6-27B本地部署实战:LM Studio配置、硬件门槛与避坑指南

大语言模型本地部署是当前AI工程落地的核心能力之一,其本质是将高参数量模型(如27B级)在受限硬件环境下实现低延迟、高稳定推理。关键技术原理涵盖量化压缩(如GGUF格式与q4_k_m精度权衡)、GPU显存分配策略(KV Cache管理与Offloading机制)、以及运行时环境兼容性(CUDA驱动、llama.cpp后端版本)。该能力直接决定私有化AI应用的技术可行性与成本边界,广泛应用于企业知识库构建、代码辅助、长文档分析等对数据主权和响应确定性要求高的场景。本文聚焦Qwen3.6-27B这一典型27B模

weixin_33272631的博客 468

PWM与光耦的完美联姻:低成本4-20mA转换方案揭秘

本文揭秘了PWM与光耦结合的低成本4-20mA转换方案,适用于工业自动化领域。通过PWM信号控制输出电流,光耦实现电气隔离,该方案成本低廉、电路简单且隔离可靠。文章详细介绍了两种经典电路实现方案,包括四光耦线性模式方案和PWM控制LM317方案,并提供了实战技巧与优化策略,帮助中小企业和电子DIY爱好者构建经济高效的4-20mA转换系统。

weixin_29229055的博客 536

【LeetCode Solutions】LeetCode 46 ~ 50 题解

【LeetCode Solutions】LeetCode 46 ~ 50 题解

一只快乐的小蒟蒻~ 915

【异常】Coze/扣子 Workflow 调用报 4200 错误深度解析

Coze API 的。

奶爸的编程之路,也就一周冷个三天 301

LeetCode 实践练习46-50

LeetCode—46(全排列) 方法一:跟77题(组合项)类似,解法基本相同,利用递归DFS来求解.这里我们需要用到一个visited数组来标记某个数字是否访问过,然后在DFS递归函数的循环应从头开始. C++代码: class Solution { public: vector&lt;vector&lt;int&gt;&gt; permute(vector&lt;int&gt;&am...

qq_40104034的博客 203

科研必备:15款顶尖AI科研工具全面分析汇总(持续更新ing)

科研必备:15款AI科研工具全面分析汇总(持续更新ing)

Code_流苏:在代码中寻诗意,在实践中觅真知 9653

PyTorch 面试题及参考答案(精选100道)

模块是 PyTorch 中用于自动求导的核心模块。它为张量上的所有操作提供了自动求导的功能。在深度学习中,反向传播是一种用于计算损失函数相对于模型参数的梯度的算法。通过梯度,我们可以使用优化算法(如随机梯度下降)来更新模型的参数,从而最小化损失函数。模块的主要作用就是自动计算这些梯度。当我们创建一个张量时,如果将其属性设置为True,那么 PyTorch 会跟踪该张量上的所有操作。在完成前向传播计算出损失函数后,调用方法,模块会自动根据链式法则反向传播计算出所有需要求导的张量的梯度。

大模型大数据攻城狮的专栏 1681

力扣爆刷第112天之CodeTop100五连刷46-50

题目链接:https://leetcode.cn/problems/compare-version-numbers/description/题目链接:https://leetcode.cn/problems/generate-parentheses/description/题目链接:https://leetcode.cn/problems/add-two-numbers/description/题目链接:https://leetcode.cn/problems/sort-list/description/

qq_43511039的博客 447

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

力扣爆刷第92天之hot100五连刷46-50

题目链接:https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/description/?题目链接:https://leetcode.cn/problems/lowest-common-ancestor-of-a-binary-tree/description/?题目链接:https://leetcode.cn/problems/path-sum-iii/description/?

qq_43511039的博客 709

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

leetcode题解python版:46-50

46、全排列 给定一个 没有重复 数字的序列,返回其所有可能的全排列。 解法一:用递归的方法,考虑n-1的情况,最后再加上nums[i]。停止条件为nums空或len(nums)<2。 class Solution: def permute(self, nums: List[int]) -> List[List[int]]: n=len(nums) if not nums or n<2: return [nums]

baidu_41689104的博客 308

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

【JavaScript】LeetCode:46-50

【代码】【JavaScript】LeetCode:46-50。

weixin_45980065的博客 868

leetcode-腾讯精选练习(50 题)python #46 全排列

leetcode-腾讯精选练习(50 题)python #46 全排列 题目来源:https://leetcode-cn.com/problemset/50/ 给定一个没有重复数字的序列,返回其所有可能的全排列。 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] class Solution: ...

楚天云 263

LeetCode 算法系列:第 46 ~50题

目录 全排列 全排列 II 旋转图像 字母异位词分组 Pow(x, n) 46. 全排列 题目描述 给定一个 没有重复 数字的序列,返回其所有可能的全排列。 示例: 输入: [1,2,3] 输出: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],[3,2,1] ] 思路: (回溯) O(n×n!) 我们从前往后,一位一位枚举,每次选择一个没有被使用过的数。 选好之后,将该数的状态改成“已被使用”,同时将该数记录在相应位置上,然后递归

逍遥云的博客 270

每日5题Day10 - LeetCode 46 - 50

【代码】每日5题Day10 - LeetCode 46 - 50。

alimamaalala的博客 440

【LeetCode高频SQL50题-基础版】打卡第9天:第46~50题

在这个博客专栏中,我将为大家提供关于 LeetCode 高频 SQL 题目的基础版解析。LeetCode 是一个非常受欢迎的编程练习平台,其中的 SQL 题目涵盖了各种常见的数据库操作和查询任务。对于计算机科班出身的同学来说,SQL 是一个基础而又重要的技能。不仅在面试过程中经常会遇到 SQL 相关的考题,而且在日常的开发工作中,掌握 SQL 的能力也是必备的。本专栏的目的是帮助读者掌握 LeetCode 上的高频 SQL 题目,并提供对每个题目的解析和解决方案。

热爱编程、热爱生活、热爱探索 848

面试笔试杂项积累-leetcode 46-50

46.46-Permutations-Difficulty:Medium Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [1,2,3], [1,3,2], [2,1,3],

wolf96的专栏 748

leetcode 腾讯50题 46/50删除链表结点

思路 给的是要删除的结点的地址,删除一个结点需要找到他的前驱,而这需要O(n)复杂度,为了能O(1)完成,可以将下一个结点的值拿过来,然后将后一个值的结点删除即可 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(...

qq_34673038的博客 127

LeetCode腾讯50题-Day6-43/46/53

LeetCode50题(17天)-Day6 43 字符串相乘 题号:43 难度:中等 https://leetcode-cn.com/problems/multiply-strings/ 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 示例 1: 输入: num1 = "2", num2 = "3" 输出: "6" 示例 2: 输入: num1 = "123", num2 = "456" 输出: "56088" 示

weixin_43760925的博客 341

leetcode—python 50天刷题 第46题 删除链表中的节点

题目描述 请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点,你将只被给定要求被删除的节点。 现有一个链表 – head = [4,5,1,9],它可以表示为: 示例 1: 输入: head = [4,5,1,9], node = 5 输出: [4,1,9] 解释: 给定你链表中值为 5 的第二个节点,那么在调用了你的函数之后,该链表应变为 4 -> 1 -> 9. 示例 2:...

weixin_45556991的博客 145

LeetCode 腾讯精选练习50--43, 46, 53

43. 字符串相乘 给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。 示例 1: 输入: num1 = “2”, num2 = “3” 输出: “6” 【思路】 注意哦,这道题的本意并不是让我们把字符串变为整数直接返回运算结果,考的其实是进位的计算。 所以我们需要使用原始竖式乘法的方法去计算,并且优化。本菜鸡目前只能写出如下代码,储存进位和当前位的方法目前还不能熟练掌握。 【实现】 class Solution: d

yiyang的博客 255

leetcode腾讯精选练习50(46)——237.删除链表节点

leetcode腾讯精选练习50(46)——237.二叉树的最近公共祖先 题目描述 请编写一个函数,使其可以删除某个链表中给定的(非末尾)节点,你将只被给定要求被删除的节点。 现有一个链表 – head = [4,5,1,9],它可以表示为: 示例 1: 输入: head = [4,5,1,9], node = 5 输出: [4,1,9] 解释: 给定你链表中值为 5 的第二个节点,那么在调用了你...

优快云zhwk的博客 310
上一篇: leetcode(41-45)
下一篇: 机器学习---KNN
小小螺丝刀
博客等级 码龄10年 41粉丝 45原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值