add
This commit is contained in:
parent
7ca8b56944
commit
2ffcfa0617
60
5.leetcode/src/com/fanxb/common/Q1744.java
Normal file
60
5.leetcode/src/com/fanxb/common/Q1744.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package com.fanxb.common;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date: 2020/6/9 15:10
|
||||||
|
*/
|
||||||
|
public class Q1744 {
|
||||||
|
|
||||||
|
public boolean[] canEat(int[] candiesCount, int[][] queries) {
|
||||||
|
long[] daySum = new long[candiesCount.length];
|
||||||
|
long sum = 0;
|
||||||
|
for (int i = 0; i < candiesCount.length; i++) {
|
||||||
|
sum += candiesCount[i];
|
||||||
|
daySum[i] = sum;
|
||||||
|
}
|
||||||
|
boolean[] res = new boolean[queries.length];
|
||||||
|
for (int i = 0; i < queries.length; i++) {
|
||||||
|
int[] query = queries[i];
|
||||||
|
long maxNum = (long) query[2] * (query[1] + 1);
|
||||||
|
if (maxNum >= daySum[query[0]]) {
|
||||||
|
res[i] = (query[1] + 1) <= daySum[query[0]];
|
||||||
|
} else {
|
||||||
|
res[i] = query[0] == 0 || maxNum > daySum[query[0] - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
// System.out.println(Arrays.toString(new Q1744().canEat(new int[]{}
|
||||||
|
// , new int[][]{{48942, 869704869, 212630006}})));
|
||||||
|
Node a = new Node(1);
|
||||||
|
Node b = new Node(2);
|
||||||
|
Node c = new Node(3);
|
||||||
|
Node d = new Node(4);
|
||||||
|
a.next = b;
|
||||||
|
b.next = c;
|
||||||
|
c.next = d;
|
||||||
|
Node last = null, current = a, next = a.next;
|
||||||
|
while (current.next != null) {
|
||||||
|
current.next = last;
|
||||||
|
last = current;
|
||||||
|
current = next;
|
||||||
|
next = next.next;
|
||||||
|
}
|
||||||
|
current.next = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Node {
|
||||||
|
private int val;
|
||||||
|
private Node next;
|
||||||
|
|
||||||
|
public Node(int val) {
|
||||||
|
this.val = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
5.leetcode/src/com/fanxb/common/Q2.java
Normal file
22
5.leetcode/src/com/fanxb/common/Q2.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.fanxb.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 两数相加
|
||||||
|
*
|
||||||
|
* @author fanxb
|
||||||
|
* @date 2021/6/1
|
||||||
|
**/
|
||||||
|
public class Q2 {
|
||||||
|
public static class ListNode {
|
||||||
|
int val;
|
||||||
|
ListNode next;
|
||||||
|
|
||||||
|
public ListNode(int val) {
|
||||||
|
this.val = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,5 @@ public class Q46 {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(new Q46().translateNum(12258));
|
System.out.println(new Q46().translateNum(12258));
|
||||||
new Thread().getState();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user