本文準(zhǔn)備講解1個(gè)簡(jiǎn)單的算法編程問題, 這個(gè)算法編程問題來(lái)自LintCode平臺(tái)。不了解.LintCode平臺(tái)的讀者可以閱讀筆者文章(在線編程平臺(tái)推薦-LeetCode)常拓。問題的英文版本描述如下:
Position
For a sorted array and a target, return the target?index.?
Example
[1,3,5,6], 5 → 2
[1,3,5,6], 2 → 1
[1,3,5,6], 7 → 4
[1,3,5,6], 0 → 0
介紹1種簡(jiǎn)單高效的算法匙姜。
簡(jiǎn)單高效的算法