File tree 3 files changed +45
-0
lines changed
3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 24
24
25
25
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
26
26
hs_err_pid *
27
+ /leetcode.iml
Original file line number Diff line number Diff line change
1
+ /**
2
+ * https://leetcode.com/explore/challenge/card/june-leetcoding-challenge/539/week-1-june-1st-june-7th/3348/
3
+ */
4
+ public class DeleteNodeInLinkedList {
5
+
6
+ // WTF?
7
+ public void deleteNode (ListNode node ) {
8
+
9
+ node .val = node .next .val ;
10
+ node .next = node .next .next ;
11
+
12
+ }
13
+
14
+ public class ListNode {
15
+ int val ;
16
+ ListNode next ;
17
+ ListNode (int x ) { val = x ; }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ import java .util .Arrays ;
2
+
3
+ /**
4
+ * See TwoCityScheduling_1029.java
5
+ */
6
+ public class TwoCityScheduling {
7
+
8
+ public static int twoCitySchedCost (int [][] costs ) {
9
+
10
+ int [] diff = new int [costs .length ];
11
+ int sum = 0 ;
12
+ for (int i = 0 ; i < costs .length ; i ++) {
13
+ diff [i ] = costs [i ][0 ] - costs [i ][1 ];
14
+ sum += costs [i ][0 ];
15
+ }
16
+
17
+ Arrays .sort (diff );
18
+
19
+ for (int i = diff .length / 2 ; i < diff .length ; i ++) {
20
+ sum -= diff [i ];
21
+ }
22
+
23
+ return sum ;
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments