Pastebin
API
tools
faq
paste
Login
Sign up
SHARE
TWEET
Untitled
a guest
Feb 19th, 2018
71
0
Never
Add comment
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!
text
0.23 KB
| None
|
0
0
raw
download
clone
embed
print
report
## Code
class Array
def dups
m = []
!! self.inject(Hash.new(0)) {|c,x|
!! c[x] += 1
!! m << x if c[x] > 1
!! c
!! }
m
end
end
a = [1,2,3,4,4,5,2]
puts a.dups.inspect
## Result
[2, 4]
Add Comment
Please,
Sign In
to add comment
Public Pastes
Vercel fix reload with Vite
JSON | 22 min ago | 0.07 KB
ДЗ Динамический массив
C# | 22 min ago | 2.10 KB
2 log
HTML | 28 min ago | 0.07 KB
🤑 G2A.com Free Gift Card Guide May 2024 FIX 🎁
GetText | 38 min ago | 0.38 KB
🤑 G2A.com Free Gift Card Guide May 2024 FIX 🤑
GetText | 40 min ago | 0.39 KB
example_compare_anagrams
Python | 43 min ago | 3.21 KB
is_anagram
Python | 44 min ago | 1.50 KB
List & Loops
YAML | 53 min ago | 1.27 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!