当前位置:网站首页>C language leetcode deleting duplicate items in an ordered array
C language leetcode deleting duplicate items in an ordered array
2022-06-11 23:39:00 【Frank. Ren】
To give you one Ascending order Array of nums , Would you please In situ Delete duplicate elements , Make each element Only once , Returns the new length of the deleted array . Elemental Relative order It should be maintained Agreement .
Because the length of an array cannot be changed in some languages , So you have to put the result in an array nums The first part of . More formally , If there is... After deleting duplicates k Elements , that nums Before k An element should hold the final result .
Insert the final result into nums Before k Return to... After a position k .
Don't use extra space , You must be there. In situ Modify input array And using O(1) Complete with extra space


int removeDuplicates(int* nums, int numsSize){
if(numsSize==0)
{
return 0;
}
int quick = 1;
int con = 1;
while(quick<numsSize)
{
if(nums[quick-1]!=nums[quick])
{
nums[con]=nums[quick];
con++;
}
quick++;
}
return con;
}Code placed github: stay c_dailywork in
https://github.com/frankRenlf/c_dailyWork.git
https://github.com/frankRenlf/c_dailyWork.git
In this folder
边栏推荐
- Software installation and use, etc
- Acwing's first question solution attracted the first fan!!! Happy~~~
- 产品力进阶新作,全新第三代荣威RX5盲订开启
- Solr之基礎講解入門
- 栈(C语言)
- Les produits antigéniques entrent dans la famille et les entreprises chinoises de dispositifs médicaux accueillent un nouvel océan bleu
- Application of Lora technology in long distance wireless transmission of water meter reading
- Data processing and visualization of machine learning [iris data classification | feature attribute comparison]
- Introduction and installation steps of sonarqube
- El scrollbar display horizontal scroll bar
猜你喜欢

Read the logstash principle
![[Day8 literature extensive reading] space and time in the child's mind: evidence for a cross dimensional symmetry](/img/c2/e70e7c32c5dc5554dea29cb4627644.png)
[Day8 literature extensive reading] space and time in the child's mind: evidence for a cross dimensional symmetry

HMS core shows the latest open capabilities in mwc2022, helping developers build high-quality applications

Solve the problem of slow downloading plug-ins for idea

Lake Shore - supertran continuous flow cryogenic thermostat system

Are you still struggling with the gold content of PMP

移印工艺流程及应用注意事项

CD process

Mysql5 and mysql8 are installed at the same time
![[Day2 intensive literature reading] time in the mind: using space to think about time](/img/7a/b155ee0c136f911a7e99e9633af246.png)
[Day2 intensive literature reading] time in the mind: using space to think about time
随机推荐
C collection of questions for project review
Introduction aux bases de SOLR
Beginner JS BOM implementation window centered
(greedy + longest ascending subsequence) acwing 896 Longest ascending subsequence II
Introduction and installation steps of sonarqube
Display product details [project mall]
[day11-12 intensive literature reading] on languages in memory: an internal clock account of space-time interaction
CD process
Live broadcast preview | featurestore meetup V3 is coming!
Figure overview of neural network
抗原產品進入家庭,中國醫療器械企業迎來新藍海
Wake up wrist - neural network and deep learning (tensorflow application) updating
[day1/5 literature intensive reading] speed constancy or only slowness: what drives the kappa effect
(linear DP | monotone queue) acwing 895 Longest ascending subsequence
队列(C语言)
How to completely modify the user name in win10 system and win11 system
Setting alias alias and @ reference note
【自然语言处理】【多模态】ALBEF:基于动量蒸馏的视觉语言表示学习
双向带头循环链表(C语言)
栈(C语言)