当前位置:网站首页>Leecode brush question record sword finger offer 56 - ii Number of occurrences of numbers in the array II
Leecode brush question record sword finger offer 56 - ii Number of occurrences of numbers in the array II
2022-07-07 00:12:00 【Why is there a bug list】
topic
In an array nums Except that a number appears only once , The other numbers appear three times . Please find the number that only appears once .
Example 1:
Input :nums = [3,4,3,3]
Output :4
Example 2:
Input :nums = [9,1,7,9,7,9,7]
Output :1
Limit :
1 <= nums.length <= 10000
1 <= nums[i] < 2^31
answer
class Solution {
public int singleNumber(int[] nums) {
int j=0;
for(int i = 0;i<nums.length;i++)
{
if(i==j)
{
i++;
if(i==nums.length)
return nums[i-1];
}
if(nums[j]==nums[i]) {
j++; // repeated
i=0;
}
}
return nums[j];
}}
边栏推荐
- Gradle knowledge generalization
- MIT 6.824 - Raft学生指南
- Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
- 2022/2/11 summary
- 1000 words selected - interface test basis
- TypeScript中使用类型别名
- Matplotlib draws a histogram and adds values to the graph
- 2022/2/12 summary
- Google, Baidu and Yahoo are general search engines developed by Chinese companies_ Baidu search engine URL
- How to find out if the U disk file of the computer reinstallation system is hidden
猜你喜欢
随机推荐
ldap创建公司组织、人员
DAY ONE
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
Cas d'essai fonctionnel universel de l'application
从外企离开,我才知道什么叫尊重跟合规…
【精品】pinia 基于插件pinia-plugin-persist的 持久化
(leetcode) sum of two numbers
什么是响应式对象?响应式对象的创建过程?
pinia 模块划分
Leecode brush questions record interview questions 32 - I. print binary tree from top to bottom
使用yum来安装PostgreSQL13.3数据库
【自动化测试框架】关于unittest你需要知道的事
Pdf document signature Guide
DevOps可以帮助减少技术债务的十种方式
Geo data mining (III) enrichment analysis of go and KEGG using David database
MATLIB从excel表中读取数据并画出函数图像
DAY ONE
三句话简要介绍子网掩码
How about the order management of okcc call center









