本站消息

  出租广告位,需要合作请联系站长

  今日名言-想象你自己对困难作出的反应,不是逃避或绕开它们,而是面对它们,同它们打交道,以一种进取的和明智的方式同它们奋斗 。——马克斯威尔·马尔兹

  今日名言-用谅解、宽恕的目光和心理看人、待人。人就会觉得葱笼的世界里,春意盎然,到处充满温暖。——蔡文甫


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

Python 刷Leetcode题库,顺带学英语单词(48)

发布于2021-07-25 06:53     阅读(737)     评论(0)     点赞(4)     收藏(1)


Contains Duplicate

Given an array of integers, find if the array contains any duplicates.    [#217]
Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.

Examples:
Input: [1,2,3,1]
Output: true
Input: [1,2,3,4]
Output: false
Input: [1,1,1,3,3,4,3,2,4,2]
Output: true

 

 


Contains Duplicate II

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.    [#219]

Examples:
Input: nums = [1,2,3,1], k = 3
Output: true
Input: nums = [1,0,1,1], k = 1
Output: true
Input: nums = [1,2,3,1,2,3], k = 2
Output: false


Contains Duplicate III

Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference between i and j is at most k.    [#220]

Examples:
Input: nums = [1,2,3,1], k = 3, t = 0
Output: true
Input: nums = [1,0,1,1], k = 1, t = 2
Output: true
Input: nums = [1,5,9,1,5,9], k = 2, t = 3
Output: false



所属网站分类: 技术文章 > 博客

作者:你做的菜有点咸

链接:http://www.pythonpdf.com/blog/article/443/bc65dc8099d54fd7293e/

来源:编程知识网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

4 0
收藏该文
已收藏

评论内容:(最多支持255个字符)