[TDD] leet code 219. Contains Duplicate II

TDD · hkliya · Created at · 924 hits
1

用 TDD 來練習完成 leet code 的第 219 題,題目描述如下。
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.
題目解釋:給一個int[] nums,以及一正整數k,如果存在著 i 與 j 使得nums[i] = nums[j],且|i-j|<= k,則回傳true。若不然,則回傳 false。

http://www.jianshu.com/p/c63a5c9a2f8c?utm_campaign=hugo&utm_medium=reader_share&utm_content=note&utm_source=weixin-timeline&from=timeline&isappinstalled=1


「软件匠艺社区」旨在传播匠艺精神,通过分享好的「工作方式」和「习惯」以帮助程序员更加快乐高效地编程。
No Reply at the moment.
需要 Sign In 后回复方可回复, 如果你还没有账号你可以 Sign Up 一个帐号。