Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
51 lines (40 loc) · 1.08 KB

File metadata and controls

51 lines (40 loc) · 1.08 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package array;
public class ArrayMain {
public static void main(String[] args) {
// DynamicArray array = new DynamicArray(10);
// for (int i = 0; i < 10; i++) {
// array.addLast(i);
// }
//
// System.out.println(array.toString());
//
// for (int i = 0; i < 10; i++) {
// array.addLast(i);
// }
//
// System.out.println(array.toString());
//
//
// array.remove(0);
// System.out.println(array.toString());
//时间复杂度分析
//大O 描述的是算法的运行时间和输入数据的关系
//eg1
//O(n) n在程序中代表的含义不一样 goto: eg1
}
/**
* eg1 O(n) n为nums中元素个数 算法和n成线性关系
* 为什么要用大O,叫做O(n) 忽略很多常数,T = c1 * n + c2
* c1 是执行一次的时间
*
* @param nums 数组
* @return 数组求和
*/
public static int sum(int[] nums) {
int sum = 0;
for (int num : nums) {
sum += num;
}
return sum;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.