Skip to content

Commit 540de3a

Browse files
author
fan
committed
a
1 parent c2a84fd commit 540de3a

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

CF/gp/hf1.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,4 +628,49 @@ public class Solution {
628628

629629
return res;
630630

631+
632+
633+
public class Solution {
634+
/**
635+
* @param points a list of points
636+
* @param origin a point
637+
* @param k an integer
638+
* @return the k closest points
639+
*/
640+
private Point global_origin = null;
641+
public Point[] kClosest(Point[] points, Point origin, int k) {
642+
// Write your code here
643+
global_origin = origin;
644+
PriorityQueue<Point> pq = new PriorityQueue<Point> (k, new Comparator<Point> () {
645+
@Override
646+
public int compare(Point a, Point b) {
647+
int diff = getDistance(b, global_origin) - getDistance(a, global_origin);
648+
if (diff == 0)
649+
diff = b.x - a.x;
650+
if (diff == 0)
651+
diff = b.y - a.y;
652+
return diff;
653+
}
654+
});
655+
656+
for (int i = 0; i < points.length; i++) {
657+
pq.offer(points[i]);
658+
if (pq.size() > k)
659+
pq.poll();
660+
}
661+
662+
k = pq.size();
663+
Point[] ret = new Point[k];
664+
while (!pq.isEmpty())
665+
ret[--k] = pq.poll();
666+
return ret;
667+
}
668+
669+
private int getDistance(Point a, Point b) {
670+
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
671+
}
672+
}
673+
674+
//Course Schedule
675+
631676
```

isi/1Notes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,10 @@ mount /mnt/source
143143

144144
AA009ANG87 850186966901249195061148
145145

146+
147+
148+
1: setup the workstation && impl the unit test for bug 257705
149+
2: Armin assign anther bug from bug pool which is bug 254932 to me
150+
3: Since Armin is not in the bugpool team, if so we can do tegther.
151+
4: I thought that I will debug the bugs from bugpool with menter.
152+
4: Do you think I can do debug with Wei. Since both of us are not comfident to fix the bugs from bugpool independently.

isi/tech.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,56 @@
1+
https://github.west.isilon.com/isilon/onefs.git
2+
3+
pip install --trusted-host artifactory.west.isilon.com --index-url http://artifactory.west.isilon.com:8081/artifactory/api/pypi/pypi-repo/simple isilon-ducttape-cli
4+
5+
dt --owner fzhou vcluster create --num-ips 4 BR_MASTER --location seattle
6+
10.7.147.6
7+
8+
dt --owner arahimi vcluster create BR_MASTER --location sea1 --num-nodes 1
9+
10+
111
```cpp
12+
13+
TEST(conflicting_rules)
14+
{
15+
struct isi_error *error = NULL;
16+
struct flx_rule rule_1 = {};
17+
int idx;
18+
19+
for(idx = 0; idx < 1; idx++) {
20+
error = NULL;
21+
init_config(idx);
22+
23+
/*
24+
* Setup two bonding conflicted rules.
25+
*/
26+
flx_rule_clean(&rule_1);
27+
28+
flx_rule_set_name(&rule_1, "rule_1");
29+
flx_rule_set_name(&rule_1, "rule_1");
30+
31+
/*
32+
* Try adding the rule 1 first and then the rule 1
33+
*/
34+
flx_pool_add_rule(pool, &rule_1, false, &error);
35+
fail_if_error(error);
36+
37+
flx_pool_add_rule(pool, &rule_1, false, &error);
38+
fail_unless(error != null);
39+
40+
flx_pool_remove_rule(pool, &rule_1, &error);
41+
fail_if_error(error);
42+
43+
flx_pool_add_rule(pool, &rule_1, false, &error);
44+
fail_if_error(error);
45+
46+
flx_rule_clean(&rule_1);
47+
48+
if (config != NULL) {
49+
flx_config_free(config);
50+
config = NULL;
51+
}
52+
}
53+
254
struct flx_rule {
355
/**
456
* Increments when _dirty is set and config is saved

0 commit comments

Comments
 (0)