当前位置:网站首页>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];
}}
边栏推荐
- 2022 PMP project management examination agile knowledge points (9)
- (leetcode) sum of two numbers
- Unity 颜色板|调色板|无级变色功能
- GEO数据挖掘(三)使用DAVID数据库进行GO、KEGG富集分析
- 【精品】pinia 基于插件pinia-plugin-persist的 持久化
- Server SMP, NUMA, MPP system learning notes.
- 17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
- PostgreSQL uses pgpool II to realize read-write separation + load balancing
- The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
- Business process testing based on functional testing
猜你喜欢
【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
How to find out if the U disk file of the computer reinstallation system is hidden
Designed for decision tree, the National University of Singapore and Tsinghua University jointly proposed a fast and safe federal learning system
2022年PMP项目管理考试敏捷知识点(9)
2022/2/12 summary
Gradle knowledge generalization
STM32通过串口进入和唤醒停止模式
The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
Rider离线使用Nuget包的方法
pytest多进程/多线程执行测试用例
随机推荐
Use package FY in Oracle_ Recover_ Data. PCK to recover the table of truncate misoperation
2022年PMP项目管理考试敏捷知识点(9)
JS import excel & Export Excel
C语言输入/输出流和文件操作【二】
Typescript incremental compilation
(leetcode) sum of two numbers
什么是响应式对象?响应式对象的创建过程?
TypeScript中使用类型别名
Use source code compilation to install postgresql13.3 database
Things like random
MySQL主从之多源复制(3主1从)搭建及同步测试
PostgreSQL使用Pgpool-II实现读写分离+负载均衡
app通用功能測試用例
37页数字乡村振兴智慧农业整体规划建设方案
为什么完全背包要用顺序遍历?简要解释一下
编译logisim
STM32 enters and wakes up the stop mode through the serial port
Geo data mining (III) enrichment analysis of go and KEGG using David database
互动滑轨屏演示能为企业展厅带来什么
How about the order management of okcc call center