Skip to content

Commit 1fb813d

Browse files
committed
docs: add contains duplicate problem solution
1 parent 5c2ee64 commit 1fb813d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/easy/readme.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,36 @@ Put this code below in main.rs and run `cargo run`
983983
println!("result: {:?}", result);
984984
```
985985

986+
# 217. Contains duplicate
987+
988+
## Description
989+
990+
Given an array of integers, find if the array contains any duplicates.
991+
992+
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.
993+
994+
## Examples
995+
996+
```text
997+
Input: [1,2,3,1]
998+
Output: true
999+
1000+
Input: [1,2,3,4]
1001+
Output: false
1002+
1003+
Input: [1,1,1,3,3,4,3,2,4,2]
1004+
Output: true
1005+
```
1006+
1007+
## How to Run in main.rs
1008+
1009+
Put this code below in main.rs and run `cargo run`
1010+
1011+
```rust
1012+
let result = easy::contains_duplicate::contains_duplicate(vec![1, 2, 3, 1]);
1013+
println!("result: {:?}", result);
1014+
```
1015+
9861016
# 234. Palindrome linked list
9871017

9881018
## Description

0 commit comments

Comments
 (0)