最大水容器、我的五个最糟糕的错误、Spring Cache。
Problem: Container With Most Water
嵌套循环
class Solution {
public int maxArea(int[] height) {
int max = 0;
int l = height.length;
for (int i = 0; i < l; i++) {
for (int j = i + 1; j < l; j++) {
int min = Math.min(height[i], height[j]);
int area = min * (j - i);
if (max < area) {
max = area;
}
}
}
return max;
}
}
class Solution {
public int maxArea(int[] height) {
int maxArea = 0, l = 0, r = height.length - 1;
while (l < r) {
maxArea = Math.max(maxArea, Math.min(height[l], height[r]) * (r - l));
if (height[l] < height[r]) {
l++;
} else {
r--;
}
}
return maxArea;
}
}
My Five Worst Bugs: Lessons Learned In System Design 我的五个最糟糕的错误:系统设计中的经验教训。
Spring Cache 中 @cacheable
和 @CachePut
中 conditon
和 unless
的区别。
unless
属性只能阻止对象放进缓存,但是在这个方法调用的时候,依然会去缓存中进行查找,如果找到了匹配的值,就会返回找到的值,与之不同,如果 condition
的表达式计算结果为 false
,那么在这个方法调用的过程中,缓存是被禁用的。也就是说,不会去缓存进行查找,同时返回值也不会进行缓存中。
最近自如的甲醛房闹得沸沸扬扬,搞得我也去买了甲醛检测仪、空气净化器、紫加黑,以前重来没有想过买空气净化器。这件事情让我觉得生活中潜在的危害才是最严重的。不过有些人为了赚钱真的是够可以的。