摘要:
与上一道题及其相似 也没什么好办法 public int threeSumClosest1(int[] nums, int target) { Arrays.sort(nums); int len = nums.length; int sum = 0; int max = Integer.MAX_V 阅读全文
摘要:
简单点暴力解法 public static String st(String [] str){ // 合理性校验 if (str.length==0||str==null)return ""; // 最长前缀 随便找一个就行 for (int i = 0; i < str[0].length(); 阅读全文
摘要:
这个简单我们遍历字符串挨个加就行了 特殊情况提前处理就行了 public int romanToInt(String s) { int sum=0; // 把特殊情况提前减掉 if(s.indexOf("IV")!=-1){sum-=2;} if(s.indexOf("IX")!=-1){sum-= 阅读全文
摘要:
给定一个数组 让你求最多能装多少水 这题明确一点就行了 面积底是固定的 高会变化 水由最低的高决定的所以 我们让左右谁矮移动谁就行了 public static int maxArea(int[] height) { int maxArea = 0; int l = 0,r = height.len 阅读全文
摘要:
这题感觉难度不应该是中等 因为已经被简化了 即使没被简化也就是变更校验而已 首先我们先维护四个变量 int pop = 0;//尾数 boolean hasSign = false;// 是否开始转化 int ans = 0;// 结果 int sign = 1;//正负 然后我们再明确校验条 if 阅读全文