摘要:
每日温度 链接 class Solution { public int[] dailyTemperatures(int[] temperatures) { int n = temperatures.length; int[] res = new int[n]; Deque<Integer> stac 阅读全文
摘要:
数组中第k个最大元素 链接 class Solution { public int findKthLargest(int[] nums, int k) { PriorityQueue<Integer> q = new PriorityQueue<Integer>(k, new Comparator< 阅读全文
摘要:
寻找重复数 寻找重复数 class Solution { public int findDuplicate(int[] nums) { int len = nums.length; int l = 1, r = len - 1; while (l < r) { int mid = (l + r) / 阅读全文
摘要:
# 共享内存(不使用锁) ``` class test { private static int count = 0; public static void main(String[] args) { Thread t1 = new MyThread(0); Thread t2 = new MyTh 阅读全文
摘要:
背包 背包01 01背包 代码块 int dp[1004][1004], v[1004], w[1004]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> v[i] >> w[i]; } for 阅读全文
摘要:
试除法判定质数 bool is_prime(int x) { if (x < 2) return false; for (int i = 2; i <= x / i; i ++ ) if (x % i == 0) return false; return true; } 试除法分解质因数 void 阅读全文