liyinglan

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

code 1:

1. 没有考虑x == null的情况

2. for循环应该遍历到i>= 0的时候才退出

 

test1: x = [2, 3, 5]; y = 5

    expected = 2

    actual = 2

test2: x = [2, 3, 5]; y = 1

    expected = -1

    actual = -1

test3: x = null; y = 1

    expected = -1

    actual = -1

code2 : 

1. 没有考虑x == null的情况

2. 返回的是数组中的第一个0而不是最后一个0

test1: x = []

    expected = -1

    actual = -1

test2: x =  [1, 2, 3]

    expected = -1

    actual = -1

test3:  x = [0, 1, 2]

    expected = 0

    actual = 0

 

posted on 2016-03-10 20:50  liyinglan  阅读(119)  评论(0编辑  收藏  举报