-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
91 lines (87 loc) · 4.08 KB
/
index.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Master the Coding Interview Data Structures and Algorithms by Andrei Neagoie 2019</title>
<style>
* {
padding: 0;
margin: 0;
}
/* body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
color: #fff;
;
background-color: #000000;
background-repeat: no-repeat;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 800 800'%3E%3Cg fill-opacity='0.16'%3E%3Ccircle fill='%23000000' cx='400' cy='400' r='600'/%3E%3Ccircle fill='%23230046' cx='400' cy='400' r='500'/%3E%3Ccircle fill='%232f0052' cx='400' cy='400' r='400'/%3E%3Ccircle fill='%233b075e' cx='400' cy='400' r='300'/%3E%3Ccircle fill='%2348156a' cx='400' cy='400' r='200'/%3E%3Ccircle fill='%23552277' cx='400' cy='400' r='100'/%3E%3C/g%3E%3C/svg%3E");
background-attachment: fixed;
background-size: cover;
background-position: center;
overflow: hidden;
} */
body {
display: flex;
flex-direction: column;
align-items: center;
}
h1 {
font-size: clamp(40px, 150px, 200px);
text-align: center;
margin-bottom: 30px;
}
p {
font-size: 20px;
max-width: 800px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<h1>Open the console</h1>
<p>
Graph Challenge Have the function GraphChallenge(strArr) read strArr which will be a representation of an
undirected graph in a form similar to an adjacency list. Each element in the input will contain an integer which
will represent the population for that city, and then that will be followed by a comma separated list of its
neighboring cities and their populations (these will be separated by a colon). For example: strArr may be
["1:[5]", "4:[5]", "3:[5]", "5:[1,4,3,2]", "2:[5,15,7]", "7:[2,8]", "8:[7,38]", "15:[2]", "38:[8]"]. This graph
then looks like the following picture:
</p>
<img src="graph.jpeg" height="300" width="200" />
<p>
Each node represents the population of that city and each edge represents a road to that city. Your goal is to
determine the maximum traffic that would occur via a single road if everyone decided to go to that city. For
example: if every single person in all the cities decided to go to city 7, then via the upper road the number of
people coming in would be (8 + 38) = 46. If all the cities beneath city 7 decided to go to it via the lower road,
the number of people coming in would be (2 + 15 + 1 + 3 + 4 + 5) = 30. So the maximum traffic coming into the city
7 would be 46 because the maximum value of (30, 46) = 46.
</p>
<p>
Your program should determine the maximum traffic for every single city and return the answers in a comma
separated string in the format: city:max_traffic,city:max_traffic,... The cities should be outputted in sorted
order by the city number. For the above example, the output would therefore be:
1:82,2:53,3:80,4:79,5:70,7:46,8:38,15:68,38:45. The cities will all be unique positive integers and there will not
be any cycles in the graph. There will always be at least 2 cities in the graph.
</p>
<p>
Examples Input: ["1:[5]", "2:[5]", "3:[5]", "4:[5]", "5:[1,2,3,4]"] Output: 1:14,2:13,3:12,4:11,5:4 Input:
["1:[5]", "2:[5,18]", "3:[5,12]", "4:[5]", "5:[1,2,3,4]", "18:[2]", "12:[3]"] Output:
1:44,2:25,3:30,4:41,5:20,12:33,18:27
</p>
<!--
<script src="./LinkedList/LinkedList.js"></script>
<script src="./LinkedList/LinkedListDoubly.js"></script>
<script src="./StackQueue/StacksQueues.js"></script>
<script src="./Tree/BinaryTree.js"></script>
<script src="./Graphs/Graph.js"></script>
<script src="./sorting/Bubble.js"></script>
-->
<script src="./algorithm/sorting/Merge.js"></script>
<script src="./index.js"></script>
</body>
</html>