摘要:
2020-02-03 20:43:46 问题描述: 问题求解: public boolean canTransform(String start, String end) { int n = start.length(); List<int[]> s = new ArrayList<>(); Lis 阅读全文
摘要:
2020-01-30 22:22:58 问题描述: 问题求解: 解法一:floyd 这个题目一看就是floyd解最合适,因为是要求多源最短路,floyd算法是最合适的,时间复杂度为O(n ^ 3)。 int inf = (int)1e9; public int findTheCity(int n, 阅读全文
摘要:
2020-01-23 19:39:26 问题描述: 问题求解: public int maxWidthRamp(int[] A) { Stack<Integer> stack = new Stack<>(); int res = 0; int n = A.length; for (int i = 0 阅读全文
摘要:
2020-01-21 21:43:52 问题描述: 问题求解: 这个题目还是有点难度的,感觉很巧妙也很难想到。 整体的思路如下: 1. 首先原问题等价于 +0 / + 2*K 2. 那么res = Max - Min 3. 不断更新Max,Min期望得到更小的res public int small 阅读全文
摘要:
2020-01-20 22:32:28 问题描述: 问题求解: 双指针 + 贪心。 public int bagOfTokensScore(int[] tokens, int P) { Arrays.sort(tokens); int res = 0; int curr = 0; int l = 0 阅读全文