@@ -0,0 +1,32 @@
+/**
+ * 给定一个长度为 n 的整数数组 height 。有 n 条垂线,第 i 条线的两个端点是 (i, 0) 和 (i, height[i]) 。
+ * 找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。
+ * 返回容器可以储存的最大水量。
+ * 说明:你不能倾斜容器。
+ * 来源:力扣(LeetCode)
+ * 链接:https://leetcode.cn/problems/container-with-most-water
+ * 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
+ *
+ * @author apple
+ * @date 2022/06/04
+ */
+public class Solution11 {
+
+ public int maxArea(int[] height) {
+ int res = 0;
+ int left = 0, right = height.length - 1;
+ while (left < right) {
+ res = Math.max(res, Math.min(height[left], height[right]) * (right - left));
+ if (height[left] < height[right]) {
+ left++;
+ } else {
+ right--;
+ }
+ return res;
+ public static void main(String[] args) {
+ System.out.println(new Solution11().maxArea(new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7})); // 49
+}
@@ -0,0 +1,30 @@
+ * 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。
+public class Solution42 {
+ public int trap(int[] height) {
+ int lMax = 0, rMax = 0;
+ lMax = Math.max(height[left], lMax);
+ rMax = Math.max(height[right], rMax);
+ if (lMax < rMax) {
+ res += lMax - height[left];
+ res += rMax - height[right];
+ System.out.println(new Solution42().trap(new int[]{0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}) == 6);
@@ -1,5 +1,11 @@
import java.util.concurrent.TimeUnit;
+ * 红包算法
public class RedPackets {
public double[] redPackets(Double all, int num) {
double[] res = new double[num];
@@ -1,9 +1,12 @@
-import java.nio.file.Files;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.BitSet;
public class tmp {
- public static void main(String[] args) throws InterruptedException {
- TimeUnit.SECONDS.sleep(3);
+ public static void main(String[] args) throws Exception
+ {
+ MyClassLoader mcl = new MyClassLoader("/Users/apple/IdeaProjects/java-base-maven/test1/target");
+ Class<?> c1 = mcl.loadClass("Person");
+ Object obj = c1.newInstance();
+ System.out.println(obj);
+ System.out.println(obj.getClass().getClassLoader());
}