Leetcode1346. 检查整数及其两倍数是否存在

Ad hoc网络路由协议概述4——按需路由协议(2)AODV协议 (Ad-hoc on-demand distance vector algorithm protocol) AODV协议的基本流程。 阅读详情

Every day a leetcode

题目来源:1346. 检查整数及其两倍数是否存在

解法1:暴力

两个for循环。

代码:

bool checkIfExist(int* arr, int arrSize){
    int n=arrSize;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i!=j && arr[i] == 2*arr[j]) return true;
        }
    }
    return false;
}

结果:
在这里插入图片描述

解法2:hash

用hash统计arr数组的每一个值,注意正数和负数要分开处理。

代码:

#define MAX_HASH_LENGTH 2001

int abs(int x)
{
    return x>0?x:-x;
}

bool check(int* hash,int x)
{
    if(hash[2*x]>0) return true;
    if(x%2 == 0 && hash[x/2]>0) return true;
    hash[x]++;
    return false;
}

bool checkIfExist(int* arr, int arrSize){
    int n=arrSize;
    int hash_p[MAX_HASH_LENGTH];
    int hash_n[MAX_HASH_LENGTH];
    memset(hash_p,0,sizeof(hash_p));
    memset(hash_n,0,sizeof(hash_n));
    for(int i=0;i<n;i++)
    {
        int x=arr[i];
        if(x>0)
        {
            if(check(hash_p,x)) return true;
        }
        else
        {
            if(check(hash_n,abs(x))) return true;
        }
    }
    return false;
}

结果:
在这里插入图片描述

优化

我们发现,hash[i]只要大于0,是 1 是 2 完全没区别,只是有0和非0的区别。

于是,我们把hash表改成bool型。

代码:

#define MAX_HASH_LENGTH 2001

int abs(int x)
{
    return x>0?x:-x;
}

bool check(bool* hash,int x)
{
    if(hash[2*x]) return true;
    if(x%2 == 0 && hash[x/2]) return true;
    hash[x]=true;
    return false;
}

bool checkIfExist(int* arr, int arrSize){
    int n=arrSize;
    bool hash_p[MAX_HASH_LENGTH];
    bool hash_n[MAX_HASH_LENGTH];
    memset(hash_p,false,sizeof(hash_p));
    memset(hash_n,false,sizeof(hash_n));
    for(int i=0;i<n;i++)
    {
        int x=arr[i];
        if(x>0)
        {
            if(check(hash_p,x)) return true;
        }
        else
        {
            if(check(hash_n,abs(x))) return true;
        }
    }
    return false;
}

结果:
在这里插入图片描述

【SAP PO】SAP PO 接口配置完整教程之一RFC服务发布 SAP RFC开发,PO接口配置 阅读详情

相关推荐

华为BEM战略解码体系完整版(85页PPT)(文末有下载方式)

在部门层面,战略解码的核心是将公司战略逐层分解到部门,确保部门目标能够有效支撑公司战略。战略解码的关键原则包括:对公司战略和业务目标的支撑、指标选取考虑部门责任特色、对公司业务流程的支撑、战略解码,华为公司实现了从战略制定到执行的闭环管理,确保了战略目标能够通过可衡量的。战略解码,华为公司实现了从战略制定到执行的闭环管理,确保了战略目标能够通过可衡量的。战略解码体系的核心目标是将公司战略逐层分解,确保战略目标能够通过可衡量的。在公司层面,战略解码的第一步是战略澄清,明确公司的使命、愿景、战略目标及。

AI_data_cloud的博客 2403

#力扣 LeetCode1346. 检查整数及其两倍数是否存在 @FDDLC

题目描述: 1346. 检查整数及其两倍数是否存在 - 力扣(LeetCode) (leetcode-cn.com) Java代码一:主要是处理0的问题 import java.util.HashSet; class Solution { //2 <= arr.length <= 500,-10^3 <= arr[i] <= 10^3 public boolean checkIfExist(int[] arr) { HashSet<Int.

LiuXingchang的博客 340

【Codex安装使用手册】

Codex安装部署使用教程

qq_43392230的博客 4999

LeetCode刷题之1346. 检查整数及其两倍数是否存在

LeetCode刷题之1346. 检查整数及其两倍数是否存在 我不知道将去向何方,但我已在路上! 时光匆匆,虽未曾谋面,却相遇于斯,实在是莫大的缘分,感谢您的到访 ! 题目: 给你一个整数数组 arr,请你检查是否存在两个整数 N 和 M,满足 N 是 M 的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标 i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例:

胡萝卜 236

基于Python实现基于遥感指数的水体提取

基于Python实现基于遥感指数的水体提取

gis收藏家的博客 6149

慕课软件质量保证与测试(习题集)

慕课金陵科技学院.软件质量保证与测试.期末复习.习题汇总0 总目录1 绪论1.1 软件质量保证与测试的产生与发展1.2 软件缺陷,软件错误,软件故障1.3 软件质量保证与测试的意义,原则和挑战1.4 单元测试1.5 课后作业2 软件测试策略2.1 软件测试的模型,过程和生命周期2.2 软件测试的方法和技术2.3 单元测试2.4 课后作业3 黑盒测试3.1 黑盒测试概述3.2 等价类划分测试3.3 边界值测试3.4 错误推测法3.5 判定表驱动法3.6 因果图法3.7 场景法3.8 正交实验法3.9 单元测试

weixin_42473228的博客 5万+

判断非负整数是否是3的倍数_LeetCode 1346. 检查整数及其两倍数是否存在

题目1346. 检查整数及其两倍数是否存在描述给你一个整数数组 arr,请你检查是否存在两个整数 N 和 M,满足 N 是 M 的两倍(即,N = 2 * M)。更正式地,检查是否存在两个下标 i 和 j 满足:i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j]示例 1:输入:arr = [10,2,5,3] 输出:true 解释:N ...

weixin_39587010的博客 246

别再乱改宏定义了!STM32F103程序移植保姆级教程(从C8T6到ZET6实战)

本文详细解析了STM32F103程序从C8T6移植到ZET6的实战步骤,重点介绍了硬件差异、开发环境配置、时钟陷阱及外设处理等关键点。通过修改宏定义(如STM32F10X_HD)、调整启动文件和时钟配置,确保移植顺利进行。适合嵌入式开发者参考,避免常见移植问题。

weixin_42567497的博客 217

LeetCode1346. 检查整数及其两倍数是否存在

给你一个整数数组 arr,请你检查是否存在两个整数 N 和 M,满足 N 是 M 的两倍(即,N = 2 * M)。解释:N = 10 是 M = 5 的两倍,即 10 = 2 * 5。解释:N = 14 是 M = 7 的两倍,即 14 = 2 * 7。解释:在该情况下不存在 N 和 M 满足 N = 2 * M。输入:arr = [7,1,14,11]输入:arr = [10,2,5,3]输入:arr = [3,1,7,11]

???的博客 176

自动化Google Chrome的强大工具:chromedriver下载、安装、简单使用

本文介绍了 ChromeDriver 的基本概念和安装配置方法,重点讲解了如何通过 Selenium 实现 Chrome 浏览器的自动化测试。内容涵盖了 ChromeDriver 下载、版本匹配、依赖引入和简单的自动化测试脚本示例,帮助读者快速上手并避免常见问题。

曾经“等你生日那天”都遥远得像未来,如今却可欢愉的挥手说“下个十年见” 88万+

基于FPGA的时间数字转换(TDC)设计(五:基于Carry4的高精度TDC设计)

基于FPGA的时间数字转换(TDC)设计,此为第五篇:基于Carry4的高精度TDC设计。提供工程文件及MATLAB测试分析代码

sdau2005的博客 8805

LeetCode之1346. 检查整数及其两倍数是否存在

概要 题目来源链接:https://leetcode-cn.com/problems/check-if-n-and-its-double-exist/ 难度:简单 类型:数组 题目 给你一个整数数组arr,请你检查是否存在两个整数N 和 M,满足N是M的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例 示例 1: 输入...

二木成林 665

PyTorch强化学习实战(1)——强化学习(Reinforcement Learning,RL)详解

在本节中,开始进入探索强化学习 (Reinforcement Learning, RL) 之旅,首先剖析了强化学习的独特之处及其与监督学习、无监督学习范式的关系。随后系统学习了强化学习的基础形式化框架及其内部关联机制,并深入讲解了马尔可夫过程 (Markov Process, MP)、马尔可夫奖励过程 (Markov Reward Process, MRP) 和马尔可夫决策过程 (Markov Decision Process, MDP),为后续学习奠定基础。

盼小辉丶的博客 2056

LeetCode 1346. 检查整数及其两倍数是否存在

目录结构 1.题目 2.题解 1.题目 给你一个整数数组arr,请你检查是否存在两个整数N 和 M,满足N是M的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例: 输入:arr = [10,2,5,3] 输出:true 解释:N = 10 是 M = 5 的两倍,即 10 = 2 * 5 。 输入:arr = [7,1...

HarvestWu的博客 190

深度学习工具包 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 1346. 检查整数及其两倍数是否存在

【题目】1346. 检查整数及其两倍数是否存在 给你一个整数数组 arr,请你检查是否存在两个整数 N 和 M,满足 N 是 M 的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标 i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例 1: 输入:arr = [10,2,5,3] 输出:true 解释:N = 10 是 M = 5 的两倍,即 10 = 2 * 5 。 示例 2: 输入:arr = [7,

Sophia_fez的博客 410

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

python-leetcode-1346. 检查整数及其两倍数是否存在

可以使用哈希集合(Set)来高效地检查是否存在这样的数对。这个算法的时间复杂度是 O(n),因为我们只遍历了一次数组,并使用哈希集合来进行快速查找。

Lucy_wzw的博客 374

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...

LeetCode1346 检查整数及其两倍数是否存在

这道题虽然可以用简单粗暴的暴力解法解决,但它也引发我们思考是否有更优化的算法。在实际编程和算法学习中,遇到类似问题,既要掌握基础的解法,也要不断探索降低时间复杂度、提高效率的方法,这样才能在面对更复杂的问题时游刃有余。希望大家通过这道题的学习,对数组遍历和条件判断有更深入的理解,后续我们还会分享更多精彩的算法题目,敬请期待!O%281%29。

qq_64604732的博客 591

力扣之1346. 检查整数及其两倍数是否存在

示例 1: 输入:arr = [10,2,5,3] 输出:true 解释:N = 10 是 M = 5 的两倍,即 10 = 2 * 5 。 示例 2: 输入:arr = [7,1,14,11] 输出:true 解释:N = 14 是 M = 7 的两倍,即 14 = 2 * 7 。 示例 3: 输入:arr = [3,1,7,11] 输出:false 解释:在该情况下不存在 N 和 M 满足 N = 2 * M 。 /** * @param {number[]} arr * @return

zhaoge's blog 262

leetcode-1346-检查整数及其两倍数是否存在 -java版

文章目录题目代码 题目 给你一个整数数组 arr,请你检查是否存在两个整数 N 和 M,满足 N 是 M 的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标 i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例 1: 输入:arr = [10,2,5,3] 输出:true 解释:N = 10 是 M = 5 的两倍,即 10 = 2 * 5 。 示例 2: 输入:arr = [7,1,14,11] 输出:t

lingle1的博客 535

LeetCode 1346. 检查整数及其两倍数是否存在(哈希)

1. 题目 给你一个整数数组 arr,请你检查是否存在两个整数 N 和 M,满足 N 是 M 的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标 i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例 1: 输入:arr = [10,2,5,3] 输出:true 解释:N = 10 是 M = ...

Michael是个半路程序员 2506

【刷题之路】LeetCode 1346. 检查整数及其两倍数是否存在

当arr[p] < 0时,则需利用q指针向后遍历,当出现arr[q] == arr[p] / 2时,则直接返回true,当出现arr[q] > arr[p] / 2时,则说明数组中已不可能存在arr[p] / 2,则让p后移一位,q保持原位。当arr[p] > 0时,就使用q指针向后遍历,当出现arr[q] == 2 * arr[p]时,直接返回true即可,当出现arr[q] > 2 * arr[p]时候,arr[p]也在不断地减小,当然2 * arr[p]也在不断的减小,所以指针q也可以原地不动。

kk702392702的博客 634

【Leetcode 1346 】 检查整数及其两倍数是否存在—— 哈希表 战胜了 糟糕的双指针

给你一个整数数组arr,请你检查是否存在两个整数N和M,满足N是M的两倍(即,N = 2 * M更正式地,检查是否存在两个下标i和jtrueN= 10是 M= 5 的两倍,即trueN= 14是 M= 7 的两倍,即14 = 2 * 7。false在该情况下不存在 N 和 M 满足 N = 2 * M。

Caoshuang_的博客 460

力扣 #1346 检查整数及其两倍数是否存在 (Leetcode #1346 Check If N and Its Double Exist)

2. 遍历数组,以i下标开始,从0开始,将下标为i的元素与相同数组中的其他元素(即下标为j并且i!=j)的两倍进行对比,如果相等,返回true,如果不相等,返回false。一句话概括:将数组中每个元素与除本元素外其他元素的两倍进行对比,如果相等,返回true,反之返回false。1. 如果数组是空的,直接返回false。

Byte_Me_A_Bit的博客 221

【Python】【难度:简单】Leetcode 1346. 检查整数及其两倍数是否存在【完】

给你一个整数数组arr,请你检查是否存在两个整数N 和 M,满足N是M的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例 1: 输入:arr = [10,2,5,3] 输出:true 解释:N = 10 是 M = 5 ...

thomashhs12的博客 339

【leetcode-13】1346. 检查整数及其两倍数是否存在

题目描述 给你一个整数数组 arr,请你检查是否存在两个整数 N 和 M,满足 N 是 M 的两倍(即,N = 2 * M)。 更正式地,检查是否存在两个下标 i 和 j 满足: i != j 0 <= i, j < arr.length arr[i] == 2 * arr[j] 示例 1: 输入:arr = [10,2,5,3] 输出:true 解释:N = 10 是 M = 5 的...

u010659877的专栏 265
上一篇: Leetcode876. 链表的中间结点
下一篇: Leetcode83. 删除排序链表中的重复元素
UestcXiye
博客等级 码龄8年 9031粉丝 1306原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

UestcXiye

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

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

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

打赏作者

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

抵扣说明:

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

余额充值