Skip to content

Commit ec31382

Browse files
author
fan
committed
a
1 parent a4bc2bb commit ec31382

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

CF/gp/hf1.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,4 +717,60 @@ private Point global_origin = null;
717717
private int getDistance(Point a, Point b) {
718718
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
719719
}
720+
721+
722+
723+
public int[] findOrder(int numCourses, int[][] prerequisites) {
724+
// write your code here
725+
726+
HashMap<Integer, List<Integer>> graph= mapping(numCourses, prerequisites);
727+
728+
Map<Integer, Integer> indegreeMap = inDegree(numCourses,graph);
729+
730+
Queue<Integer> myQ= new LinkedList<>();
731+
int re[] = new int[numCourses];
732+
int count = numCourses -1;
733+
734+
for(int i = 0; i < numCourses; i++){
735+
if(!indegreeMap.containsKey(i)){
736+
myQ.offer(i);
737+
re[count--] = i;
738+
}
739+
}
740+
741+
while(!myQ.isEmpty()){
742+
743+
Integer temp = myQ.poll();
744+
for(Integer item: graph.get(temp)){
745+
indegreeMap.put(item, indegreeMap.get(item) -1);
746+
747+
if( indegreeMap.get(item) ==0 ){
748+
myQ.offer(item);
749+
re[count--] = item;
750+
}
751+
}
752+
753+
}
754+
755+
if(count != -1){
756+
return new int[0];
757+
}
758+
759+
return re;
760+
761+
}
762+
763+
private HashMap<Integer, List<Integer>> mapping(int numCourses, int[][] prerequisites){
764+
765+
HashMap<Integer, List<Integer>> map = new HashMap<>();
766+
for (int i = 0; i < numCourses; i++) {
767+
map.put(i, new ArrayList<>());
768+
}
769+
for (int i = 0; i < prerequisites.length; i++) {
770+
int cur = prerequisites[i][0];
771+
int pre = prerequisites[i][1];
772+
map.get(cur).add(pre);
773+
}
774+
return map;
775+
}
720776
```

isi/tech.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ dt --owner arahimi vcluster create BR_MASTER --location sea1 --num-nodes 1
99

1010
wget http://cribsbiox.west.isilon.com/home/cclayton/public/bug/bug254932/python2.7.core.gz
1111
gdbcore `which python2.7` /root/python2.7.core.gz /mnt/bb/b.master.112/obj.RELEASE/symbols
12+
13+
make isi-isilon isi-isilon-install OVERRIDE=isilon/lib/isi_flexnet
14+
pkill isi_papi_d
15+
isi network rules create groupnet0.subnet0.pool0.rule22 ext-1 --description 'practice rule 22'
1216

17+
1318
```cpp
1419

1520
TEST(conflicting_rules)

0 commit comments

Comments
 (0)