关于面试的一道代码题
当时没写出来。。。面完去上了个厕所就想出来了。。。。。。。。。
题目大意:
在一个从大到小的数组的中找到一个数第一次出现和最后一次出现的索引。
实现:
func main() {
fmt.Println(match([]int{0, 1, 1, 2, 3, 4, 17}, 1)) // 1 2
fmt.Println(match([]int{0, 1, 1, 2, 3, 4, 17}, 3)) // 4 4
}
func match(ints []int, target ...
fzdwx.hashnode.dev1 min read
Li Ke
he is a programmer.
今天面试又遇到了这个题目,但是面试官说我这样写有问题。。
面试官反馈:可能需要你再看一下,错误比较明显