Skip to content

Commit

Permalink
problem set + solution
Browse files Browse the repository at this point in the history
  • Loading branch information
one-m1nd committed Dec 16, 2023
1 parent 30916ae commit 5c24516
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/leetcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'leetcode/reverse_nodes_in_k_group'
require 'leetcode/median_of_two_sorted_arrays'
require 'leetcode/regular_expression_matching'
require 'leetcode/number_after_double_reversal'
require 'leetcode/substring_with_concat_of_all_words'
require 'leetcode/count_number_of_distinct_integers_after_reverse_operations'

Expand Down
7 changes: 7 additions & 0 deletions lib/leetcode/number_after_double_reversal.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Leetcode
class NumberAfterDoubleReversal
def execute(num)
num.to_s.reverse.to_i.to_s.reverse.to_i == num
end
end
end
30 changes: 30 additions & 0 deletions spec/leetcode/number_after_double_reversal_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
RSpec.describe Leetcode::NumberAfterDoubleReversal do
describe '#execute' do
let(:num) { nil }
subject { Leetcode::NumberAfterDoubleReversal.new.execute(num) }

context '526' do
let(:num) { 526 }

it do
expect(subject).to be true
end
end

context '1800' do
let(:num) { 1800 }

it do
expect(subject).to be false
end
end

context '0' do
let(:num) { 0 }

it do
expect(subject).to be true
end
end
end
end

0 comments on commit 5c24516

Please sign in to comment.