当前位置:网站首页>Sword finger offer 53 - ii Missing numbers from 0 to n-1
Sword finger offer 53 - ii Missing numbers from 0 to n-1
2022-07-05 05:29:00 【ThE wAlkIng D】
Title Description

)
Problem analysis
Use the formula of arithmetic sequence to find n Xiang He , Then find the sum of the array , Subtract the two
Code instance
class Solution {
public int missingNumber(int[] nums) {
int n = nums.length;
int a = n * (n + 1) / 2;
int sum = 0;
for(int i = 0;i < nums.length;i++){
sum += nums[i];
}
return (a - sum);
}
}
边栏推荐
- [to be continued] [UE4 notes] L3 import resources and project migration
- 每日一题-搜索二维矩阵ps二维数组的查找
- Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
- What is the agile proportion of PMP Exam? Dispel doubts
- TF-A中的工具介绍
- Under the national teacher qualification certificate in the first half of 2022
- [to be continued] I believe that everyone has the right to choose their own way of life - written in front of the art column
- Talking about JVM (frequent interview)
- Codeforces Round #715 (Div. 2) D. Binary Literature
- Introduction to memory layout of FVP and Juno platforms
猜你喜欢

Reader writer model
![[trans]: spécification osgi](/img/54/d73a8d3e375dfe430c2eca39617b9c.png)
[trans]: spécification osgi

YOLOv5添加注意力机制

剑指 Offer 05. 替换空格

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
![[turn to] MySQL operation practice (I): Keywords & functions](/img/b1/8b843014f365b786e310718f669043.png)
[turn to] MySQL operation practice (I): Keywords & functions
![To be continued] [UE4 notes] L4 object editing](/img/0f/cfe788f07423222f9eed90f4cece7d.jpg)
To be continued] [UE4 notes] L4 object editing
![[turn to] MySQL operation practice (III): table connection](/img/70/20bf9b379ce58761bae9955982a158.png)
[turn to] MySQL operation practice (III): table connection

Gbase database helps the development of digital finance in the Bay Area

第六章 数据流建模—课后习题
随机推荐
TF-A中的工具介绍
Reflection summary of Haut OJ freshmen on Wednesday
Yolov5 adds attention mechanism
A problem and solution of recording QT memory leakage
PC寄存器
Demonstration of using Solon auth authentication framework (simpler authentication framework)
Count sort
SDEI初探-透过事务看本质
使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
Gbase database helps the development of digital finance in the Bay Area
Control Unit 控制部件
Pointnet++ learning
剑指 Offer 05. 替换空格
[trans]: spécification osgi
Warning using room database: schema export directory is not provided to the annotation processor so we cannot export
Chapter 6 data flow modeling - after class exercises
Development error notes
Hang wait lock vs spin lock (where both are used)
Acwing 4300. Two operations
Zzulioj 1673: b: clever characters???