leetcode 2225. Find Players With Zero or One Losses(找出全赢或只输一次的玩家)

Linux DRM驱动实战:手把手教你用drmModeSetCrtc显示纯色画面(附完整代码) 本文提供了一份完整的Linux DRM驱动实战指南,手把手教你使用drmModeSetCrtc在屏幕上显示纯色画面。文章详细解析了从打开设备、获取资源、创建帧缓冲区到最终提交画面的完整调用流程,并附带了可直接编译运行的完整代码示例,帮助开发者快速上手Linux图形底层开发。 阅读详情

You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match.

Return a list answer of size 2 where:

answer[0] is a list of all players that have not lost any matches.
answer[1] is a list of all players that have lost exactly one match.
The values in the two lists should be returned in increasing order.

Note:

You should only consider the players that have played at least one match.
The testcases will be generated such that no two matches will have the same outcome.

Example 1:

Input: matches = [[1,3],[2,3],[3,6],[5,6],[5,7],[4,5],[4,8],[4,9],[10,4],[10,9]]
Output: [[1,2,10],[4,5,7,8]]
Explanation:
Players 1, 2, and 10 have not lost any matches.
Players 4, 5, 7, and 8 each have lost one match.
Players 3, 6, and 9 each have lost two matches.
Thus, answer[0] = [1,2,10] and answer[1] = [4,5,7,8].

matches数组中的每个子数组代表 [ 赢家,输家 ],
找出只赢过的玩家 和 只输过一次的玩家 保存在结果list中的[0], [1] list内,
玩家要升序排列。

思路:

首先声明一下几个点,
全赢的玩家不用管它赢几次,只要没输过就行。
只输过一次的玩家是真的只输过一次,输两次赢一次也算输两次,输一次赢一次也算输一次,
是不可抵消的(亲自验证过…)。
所以不需要考虑记录赢的次数,只需要记录赢的玩家有没有输过。

方法一:
用hashSet记录赢家,如果赢家出现在输的名单上,就移除它。
注意要把所有玩家保存之后再看有没有出现在输家名单上,不能边加边check.
因为玩家并不是按顺序出现的,假如前面删过一次,它不存在了,后面又出现了,这时是加还是不加呢。
注意还要给玩家排序。

public List<List<Integer>> findWinners(int[][] matches) {
    HashSet<Integer> set_winner = new HashSet<>();
    HashMap<Integer, Integer> map_loser = new HashMap<>();
    List<Integer> arr_winner = new ArrayList<>();
    List<Integer> arr_loser = new ArrayList<>();
    List<List<Integer>> res = new ArrayList<>();
    
    for(int[] match : matches) {
        set_winner.add(match[0]);            
        map_loser.put(match[1], map_loser.getOrDefault(match[1], 0)+1);
    }
    
    for(Integer winner : set_winner) {       
        if(!map_loser.containsKey(winner)) arr_winner.add(winner);
    }
    
    for (Map.Entry<Integer, Integer> entry : map_loser.entrySet()) {
        if(entry.getValue() == 1) arr_loser.add(entry.getKey());
    }
    Collections.sort(arr_winner);
    Collections.sort(arr_loser);
    
    res.add(arr_winner);
    res.add(arr_loser);
    return res;
}

方法二:
可以发现玩家只处于4种状态,第1种:空白还没处理(0),第2种:只赢过(1),
第3种:只输过一次(2),第4种:输过多次(3)。
也不需要赢家输家单独保存,而是在数组上直接覆盖。
看下状态转移:
空白(0):赢 -> 赢(1), 输 -> 输一次(2)
赢(1): 赢 -> 不变(1), 输 -> 输一次(2)
输(2,3):赢 -> 不变(2), 输 -> 输多次(3)

因为玩家是作为数组下标出现的,肯定是升序,所以最后不需要排序。

public List<List<Integer>> findWinners(int[][] matches) {
    int[] result = new int[100001];
    List<Integer> arr_winner = new ArrayList<>();
    List<Integer> arr_loser = new ArrayList<>();
    List<List<Integer>> res = new ArrayList<>();
    int max_res = 0;
    final int WIN_NO_LOSE = 1;
    final int LOSE_ONCE = 2;
    final int LOSE_MORE = 3;
    
    for(int[] match : matches) {
        if(result[match[0]] == 0) result[match[0]] = WIN_NO_LOSE;
        result[match[1]] = result[match[1]] <= WIN_NO_LOSE ? LOSE_ONCE : LOSE_MORE;
        max_res = Math.max(max_res, Math.max(match[0], match[1]));
    }
    
    for(int i = 0; i <= max_res; i++) {
        if(result[i] == WIN_NO_LOSE) arr_winner.add(i);
        if(result[i] == LOSE_ONCE) arr_loser.add(i);
    }
    
    res.add(arr_winner);
    res.add(arr_loser);
    return res;
    
}
人工智能之数学基础:弄懂数学本质,让我们不再害怕数学 数学的用途远远超过了人们的想象,甚至无处不在,任何领域都需要用到数学知识,人工智能也不例外。我将尽可能地将数学知识和机器学习算法相结合,让大家知道这些数学知识咋人工智能领域中的应用,使得数学的学习不会过于枯燥,同时也帮助大家扫清在学习算法过程中的数学障碍。除此之外,我还希望帮助大家建立一种不一样的数学思维,不再将数学看成是符号的演算、公式的推导,而是将数学看成是一种描述这个世界的工具,这样你就会发现这个世界处处有数学。当我们面对问题的时候,你是否会对问题进行抽象,然后通过数学来解决问题? 阅读详情

相关推荐

C#读取CAD文件(dwg/dxf)并处理

项目要求识别CAD图纸(图纸内容与现实事物比例是1:1)中的内容,并提取出一些关键信息。这里的CAD图纸是指CAD文件,包含多种格式,dwg/dxf/dwf/stl/pdf等等。识别其中内容,主要指文件中的图元信息(也叫实体Entity),指线段、圆弧、矩形等图形元素。得到图元基础信息(比如长度、坐标、粗细)后,进一步做处理(如得到交点、得到线段间间隔、圆弧与线段切点等)。听起来有点难,因为作为软件工程师,对CAD相关事物并不了解,它是未知的;

三千幻想乡 1万+

Leetcode 2225. Find Players With Zero or One Losses

题目 解法1:无序hashmap+排序 maintain一个dict,记录所有loser及其lose掉的match数量。遍历所有player,如果没在loser dict出现则是答案的第一维·,如果loser dict中的value是1,则是答案的第二维,最后将答案排序 class Solution: def findWinners(self, matches: List[List[int]]) -> List[List[int]]: # win_dict = collect

qq_37821701的博客 1180

组态王|通过日历控件选择时间段查询历史报警

哈喽,你好啊,我是雷工!这节记录下查询历史报警信息的功能实现。以下为实现笔记。

做有价值的事,积累有价值的笔记! 3788

【LeetCode 热题 100】73. 矩阵置零|数组、矩阵、原地算法(Python)

【LeetCode 热题 100】【73. 矩阵置零】|数组、矩阵、原地算法(Python)

weixin_70673823的博客 313

一文读懂GPU通信互联技术:GPUDirect、NVLink与RDMA

GPUDirect是NVIDIA开发的一项技术,旨在实现GPU与其他设备(如网络接口卡NIC和存储设备)之间的直接通信和数据传输,而无需CPU的参与。传统上,数据在GPU和另一个设备之间传输时,必须通过CPU,这导致潜在的性能瓶颈和延迟增加。GPUDirect技术则通过绕过CPU,直接访问和传输数据,显著提高系统性能。NVLink是NVIDIA开发的一种高速、高带宽的互连技术,用于连接多个GPU之间或GPU与其他设备(如CPU、内存等)之间的通信。

异构算力老群群(在读985计算机博士生)的技术博客 7797

【Godot4自学手册】第一节配置Godot运行环境

Godot是一款自由开源、由社区驱动的 2D 和 3D 游戏引擎!它是一款功能丰富的跨平台游戏引擎,可以通过统一的界面创建 2D 和 3D 游戏。它提供了一套全面的通用工具,因此用户可以专注于制作游戏,而无需重新发明轮子。游戏可以一键导出到多个平台,包括主流的桌面平台(Linux、macOS、Windows)、移动平台(Android、iOS)、基于 Web 的平台以及主机平台。

zhaoyang314的博客 5995

LeetCode //C - 1320. Minimum Distance to Type a Word Using Two Fingers

This problem involves finding the minimum total distance to type a given word using two fingers on a keyboard layout where letters are arranged in a grid. The solution uses dynamic programming to track the positions of the two fingers after each keystroke,

Made in Code 541

从零到一:IC Compiler II(ICC II)后端设计流程详解

本文详细解析了IC Compiler II(ICC II)后端设计流程,从环境准备到物理实现,再到布线优化与签核验证。通过实战案例和高效技巧,帮助工程师掌握ICC II工具链的应用,提升数字集成电路设计的效率和质量。

weixin_30879169的博客 350

LeetCode Hot 100 二分查找专题 34 / 33 / 153(Java)

专题主线:三道题共用同一副二分骨架,差别只在循环条件和收缩方向: 34.在排序数组中查找元素的第一个和最后一个位置:用 left <= right 练「边界二分」, 153.寻找旋转排序数组中的最小值:用 left < right + right = mid 练「下界模板」, 33.搜索旋转排序数组:是二者的组合应用。

2401_88612756的博客 560

dify制作的工作流如何通过API调用

本文介绍了如何通过Python程序调用Dify工作流API实现数据处理功能。文章详细展示了workflow和chatflow的调用方法,包括参数设置和结果输出,并提供了一个完整的API调用工具代码示例。该工具可实现文本处理、成果查重、关键词生成等功能,支持通过Python脚本或Postman进行调用。核心代码包含API请求函数和批量处理函数,通过HTTP请求与Dify服务端交互,实现自动化数据处理流程。

hhue2007的专栏 941

Python爬虫实战:携程旅游平台数据爬取(酒店+机票+景点),破解加密与反爬(附完整代码)

携程的反爬机制再复杂,核心逻辑都是“识别非真实用户的请求”,而爬虫的核心就是“让请求看起来像真实用户的行为”。本文的方案从登录态处理、参数加密破解、动态数据抓取,到反爬应对,都是围绕“模拟真实”展开:用Playwright模拟真实浏览器登录,用住宅代理模拟真实用户IP,用随机延迟模拟真实用户的操作频率。掌握了这个核心思路,无论平台的反爬如何升级,都能找到应对方法。当然,爬虫技术是一把双刃剑,合理使用才能发挥其价值。如果你的爬虫项目中遇到了携程的反爬问题,不妨按照本文的步骤试试,大概率能解决问题。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2619

LeetCode //C - 1325. Delete Leaves With a Given Value

This problem involves removing all leaf nodes from a binary tree that have a given target value, including cases where parent nodes become new leaves with the target value after deletion. The solution uses a postorder traversal approach (left-right-root) t

Made in Code 393

【YOLO26保姆级零踩坑教程】环境搭建+五大任务快速入门,一行代码实现检测/分割/姿态/OBB/分类(Win+Linux全适配)

YOLO26环境搭建与实战指南:零踩坑全适配 本文是YOLO26全栈技术专栏的入门篇,提供Windows/Linux双系统的纯实战环境搭建指南,主打零踩坑、全适配。YOLO26基于Ultralytics框架优化,无需编译源码或手动下载权重,原生支持多任务推理。 环境配置关键点: 必须安装Ultralytics 8.4.0及以上版本 支持CPU/GPU环境,推荐Python 3.8-3.11 提供清华源配置解决下载慢问题 安装步骤: CPU版:一键安装Ultralytics和OpenCV GPU版:匹配CUD

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 783

leetcode-腐烂的橘子-双端队列记录坏橘子,取出后去感染新橘子

每分钟,腐烂的橘子 周围 4 个方向上相邻 的新鲜橘子都会腐烂。示例 1:[https://assets.leetcode.cn/aliyun-lc-upload/uploads/2019/02/16/oranges.png]输入:grid = [[2,1,1],[1,1,0],[0,1,1]]输出:4示例 2:输入:grid = [[2,1,1],[0,1,1],[1,0,1]]输出:-1解释:左下角的橘子(第 2 行, 第 0 列)永远不会腐烂,因为腐烂只会发生在 4 个方向上。每循环一次记为一分钟,

记录一点 247

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

[LeetCode] 151. 反转字符串中的单词 题解

快慢指针:规范化空格,同时保持单词原顺序;整体反转:一次性反转所有单词的顺序;逐词反转:修复整体反转造成的单词内部逆序。

2501_92746740的博客 546

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

LeetCode //C - 1326. Minimum Number of Taps to Open to Water a Garden

Summary: The problem involves finding the minimum number of taps needed to water a garden spanning from 0 to n on the x-axis. Each tap at position i can water a range centered at i with a given radius. The solution employs a greedy approach by first transf

Made in Code 194

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

LeetCode100 35.搜索插入位置

二分查找模板可高效求解插入位置。左闭右开区间下,循环终止时l即为插入下标:若target大于所有元素,l = nums.length;若在两数之间,l落在左侧。通过mid = l + (r - l) / 2避免溢出,nums[mid] < target时左移边界,否则右移,最终返回l,无需额外判断。

Shaoxingzong的博客 90

LeetCode Hot 100 栈专题(20 / 155 / 394 / 739)(Java)

本专题四道题恰好覆盖栈的三类核心用法:括号匹配(延迟匹配)、辅助栈维护额外信息(最小值)、单调栈找下一个更大元素。把这三类打通,Hot 100 里的栈题基本可以通吃。 覆盖:20.有效的括号、155.最小栈、394.字符串解码、739.每日温度

2401_88612756的博客 327

【算法刷题】LeetCode 力扣 Hot 100 刷题记录

力扣 Hot 100 刷题代码记录

2401_87820834的博客 215

LeetCode100 139.单词拆分

该解法使用动态规划判断字符串是否可被字典中的单词拆分。定义 dp[i] 表示前 i 个字符能否被成功拆分。遍历每个位置 i,尝试所有可能的分割点 j,若 dp[j] 为真且子串 s[j:i] 在字典中,则 dp[i] 设为真。一旦找到可行分割即跳出内层循环。最终返回 dp[n]。时间复杂度 O(n²),空间复杂度 O(n)。

Shaoxingzong的博客 202

[Leetcode] 回溯(多集合的笛卡尔积、子集型、组合型、排列型)

回溯

皮卡丘在充电 242

LeetCode Hot 100 堆专题 215. 数组中的第 K 个最大元素 / 347. 前 K 个高频元素(Java)

本专题收录 Hot 100 中与「堆 / 优先队列」相关的两道题:215. 数组中的第 K 个最大元素、347. 前 K 个高频元素,每题按「题目分析与解题思路 → 常见解法(附代码)与讲解 → 知识点总结」三段组织。

2401_88612756的博客 245

【LeetCode 热题 100】1. 两数之和|数组、哈希表(Python)

【LeetCode 热题 100】【1. 两数之和】|数组、哈希表(Python)

weixin_70673823的博客 259

【leetcode】179.最大数js

本题通过自定义排序规则,将数字转为字符串后,比较拼接结果 a+b 与 b+a 的大小,决定顺序。若 a+b > b+a,则 a 排在 b 前。最终需特判全零情况(如 [0,0,0]),避免输出 '000'。利用 JS sort 的比较逻辑,简洁实现最大数字拼接。

2402_83244812的博客 200

LeetCode100 73.划分字母区间

本文介绍两种解决字符串分区问题的方法:一是通过记录每个字符最后一次出现位置,遍历时维护当前区间末尾,当当前位置等于该末尾时分割;二是通过记录每个字符的起始与结束位置,合并重叠区间后计算各段长度。两者均能正确划分字符串为最小不重叠分区,返回各分区长度。

Shaoxingzong的博客 175

leetcode 3360. 移除石头游戏 简单

Alice 和 Bob 在玩一个游戏,他们俩轮流从一堆石头中移除石头,Alice 先进行操作。表示一开始石头的数目,如果 Alice 赢下这个游戏,请你返回。第一位没法进行操作的玩家输掉这个游戏。

2401_88085478的博客 200
上一篇: leetcode 907. Sum of Subarray Minimums(子数组最小值的和)
下一篇: 结合paper 详细解读yolact源码(eval)
蓝羽飞鸟
博客等级 码龄8年 1万+粉丝 727原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

蓝羽飞鸟

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

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

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

打赏作者

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

抵扣说明:

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

余额充值
⌂ 换网址