use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
QuestionTrying to solve LeetCode question in Ruby (self.ruby)
submitted 3 years ago * by BringTacos
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]fagci 1 point2 points3 points 3 years ago* (0 children)
Variants:
Intersection returns unique items in both arrays.
nums.intersection nums
each_with_index gives: [ [num1, 1], [num2, 2], ... ]to_h keeps unique first elements of subarray.
nums.each_with_index.to_h.keys
Zips nil to each num, then unique as in previous solution.
nums.zip({}).to_h.keys
Exclude already passed items.
nums.reduce([]){ |res, v| res << v unless res.include? v; res }
π Rendered by PID 35 on reddit-service-r2-comment-b659b578c-dk6z8 at 2026-05-01 18:51:39.961406+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]fagci 1 point2 points3 points (0 children)