-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathContents.swift
89 lines (43 loc) · 1.17 KB
/
Contents.swift
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
/*
Use the link here to get the questions. Then code your solutions below. If it does not require code, just write your answer in comments.
https://docs.google.com/document/d/1aF1imJUVahCSJAuN1OEm5lQXwpSFaAmVmAETKMM6PLQ/edit#heading=h.za36ai6n5fth
1) a. O(m * n)
b. O(n^2)
c. O(n^4)
2) a. O(n^4)
b. O(n)
c. O(n^2)
d. O(n)
3) a. graph
b. graph
c. hash table
4) func factorialCalc(num: Int) -> Int {
let range = Array(1...num)
var multiplier = 1
for (var i = 0; i < range.count; i++) {
multiplier *= range[i]
}
return multiplier
}
factorialCalc(5)
factorialCalc(4)
factorialCalc(9)
Time Complexity: O(n)
5) func multiplication(num: Int, times: Int) -> Int {
let range = Array(1...times)
var total = 0
for (var i = 0; i < range.count; i++) {
total += num
}
return total
}
multiplication(5, times: 2)
multiplication(10, times: 3)
multiplication(7, times: 3)
Time Complexity: O(n)
6) --
7) Don't get the question
*/