当前位置:网站首页>[array] longest continuous subsequence in nc95 array - difficult
[array] longest continuous subsequence in nc95 array - difficult
2022-07-23 23:23:00 【51CTO】
NC95 Longest continuous subsequence in array
Knowledge point Union checking set Array
describe
Given an unordered array arr, Returns the length of the longest continuous sequence ( The required value is continuous , The position can be discontinuous , for example 3,4,5,6 Is a continuous natural number )
Data range : , The values in the array meet
requirement : Spatial complexity , Time complexity
Example 1
Input :
Return value :
Example 2
Input :
Return value :
Answer key
Sort + Statistics
Ideas :
Sort the array first , Then count consecutive numbers . Be careful , If it's continuous 2 Two numbers are equal , The continuous length should not be reset at this time .
Similar to this solution, there are also uses set Store all elements and make statistics , Or use hash Table statistics ~~
The code is as follows :
Union checking set
边栏推荐
- dried food! Implicit sparse regularization effect in neural networks
- TAP 系列文章4 | 基于 Backstage 的 TAP 开发者门户
- strncat() strncmp()
- Mongodb - Introduction to the usage of logical operators not, and, or, nor in query statements
- 礪夏行動|源啟數字化:既有模式,還是開源創新?
- FL Studio 20.9 update Chinese version host Daw digital audio workstation
- AutoCAD advanced operation
- unity visual studio2019升级到2022版本(扔掉盗版红渣)
- About: enable delivery optimization in enterprise LAN
- 汇编语言伪指令详解(附实例)
猜你喜欢
![[tensorflow] check whether tensorflow GPU is available](/img/27/e2b21b0a0cecdff27ddd2af6e34949.png)
[tensorflow] check whether tensorflow GPU is available

Remember an experience of being cheated by the Internet

Flask框架中如何进行数据库的迁移

Grey prediction (matlab)

Basic operations of AutoCAD

Analysis of video capability and future development trend based on NVR Technology

strncat() strncmp()

Mongodb database + graphical tools download, installation and use

Grey correlation analysis (matlab)

Data sorting and usage before torchvision.datasets.imagefolder
随机推荐
PHP(2)
Rosbag file recorded by LIDAR point cloud data is converted into CSV file
BGP routing, MPLS
Tensorflow one layer neural network training handwritten digit recognition
Preparation for raspberry pie 3B serial port login
1000 okaleido tiger launched binance NFT, triggering a rush to buy
史上最全的2022年版Android面试题
BGP basic experiment
Light up the LED light of little bear patting learning
YOLOv4: Optimal Speed and Accuracy of Object Detection
TAP 系列文章9 | 应用开发加速器
(CVPR-2022)BiCnet
Learning MySQL is enough
A great open source micro community light forum source code
疑似未系安全带 林志颖伤势相对稳定
Tap series article 9 | application development accelerator
Open source embedded sig in the openeuler community. Let's talk about its multi OS hybrid deployment framework
System memory introduction and memory management
1、 Simplification of digital logic
Diabetes genetic risk testing challenge baseline