[TDD] leet code 219. Contains Duplicate II

TDD · hkliya · Created at · 924 hits

用 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。


No Reply at the moment.
需要 Sign In 后回复方可回复, 如果你还没有账号你可以 Sign Up 一个帐号。