Algorithm:
JAVA:
class Solution {
public int[] twoSum(int[] nums, int target) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < nums.length; i++) {
list.add(nums[i]);
}
for (int i = 0; i < nums.length; i++) {
for (int j = 0; j < list.size(); j++) {
if (i != j) {
if (nums[i] + list.get(j) == target) {
if (i < j) {
return new int[]{i, j};
} else {
return new int[]{j, i};
}
}
}
}
}
return null;
}
}
GO:
func twoSum(nums []int, target int) []int {
res := []int{}
for i, num1 := range nums {
for j, num2 := range nums {
if i != j && num1+num2 == target {
res = append(res, i)
res = append(res, j)
break
}
}
if len(res) > 0 {
break
}
}
sort.Ints(res)
return res
}
Review:https://medium.com/thewashingtonpost/what-it-means-for-us-to-actually-see-a-black-hole-4720e3356ce4
What It Means for Us to Actually ‘See’ a Black Hole
讲述了黑洞被提出以及被真正拍照的过程。现在的望远镜技术比之前提高了很多,这是拍照成功的前提。
Tip:
在使用springboot 中 入参踩坑
在springboot 中,入参使用requestParam接收 只能用get方法请求成功。 入参使用requestBody接收参数,只能用post方法请求成功。
然而,调用者使用requestMapping 进行调用入参为string类型的单一参数(String id),后端无论如何访问不成功。
网上查阅解决办法,第一种加入自定义注解,解析。第二种新建实体类包含单一属性 string id。
最后在调用方限定使用get方法请求解决问题。
Share:
网络知识科普 | 你未必了解的DNS
微信公众号上面文章 讲解dns