当前位置:网站首页>Force deduction brush question 26. Delete duplicates in the ordered array
Force deduction brush question 26. Delete duplicates in the ordered array
2022-07-25 03:21:00 【GRT should always work hard】


Use the double finger method , Ideas as follows .
class Solution {
public int removeDuplicates(int[] nums) {
if(nums.length == 0){
return 0;}
int p = 0;
int q = 1;
while(q<nums.length){
if(nums[p] != nums[q]){
nums[p+1] = nums[q];
p++;
}
q++;
}
return p+1;
}
}
边栏推荐
- [Kali's sshd service is enabled]
- The relationship between private domain traffic and fission marketing. What is super app? Can our enterprise own it?
- Li Kou 279 complete square - dynamic programming
- FLASH read / write problem of stm32cubemx
- Learning record 12
- Color space (2) -- YUV
- The dolphin scheduler calls the shell script and passes multiple parameters
- C language writes a circular advertising lantern or changes it to a confession system
- Recursive and non recursive methods are used to realize the first order, middle order and second order traversal of binary tree respectively
- The difference between abstract classes and interfaces
猜你喜欢

05 - MVVM model

04 -- two ways of writing el and data

Import and export using poi

Riotboard development board series notes (6) -- buildreoot building system image

Riotboard development board series notes (VII) -- the use of framebuffer

How chemical enterprises choose digital service providers with dual prevention mechanism

Learning record 10

Mark down learning

Flowlayout in compose

Dc-1-practice
随机推荐
Recursive and non recursive methods are used to realize the first order, middle order and second order traversal of binary tree respectively
[template engine] microservice Learning Notes 6: freemaker
mysql_ Backup restore_ Specify table_ Backup table_ Restore table_ innobackup
B. All Distinct
New features commonly used in ES6
Test question f: statistical submatrix
Reasons for not sending requests after uni app packaging
mysql_ Record the executed SQL
Innobackupex parameter description
Win10 -- open the hosts file as an administrator
Hashcode details
Learning record 10
Direct insert sort / Hill sort
Banana pie bpi-m5 toss record (2) -- compile u-boot
Backtracking to solve combinatorial problems
Download the jar package of jsqlparser and PageHelper
Vscode configuration, eslint+prettier combined with detailed configuration steps, standardized development
Resolve the error: org.apache.ibatis.binding.bindingexception
Analysis of DNS domain name resolution process
Implementation principle of virtual DOM