lib/super_digit.rb
# Time Complexity - O(n) where n is the number of digits (Is there a way to be more specific?)
# Space Complexity - O(n) where n is the number of digits; using call stack + auxiliary array
Time Complexity - O(n) where n is the number of digits (Is there a way to be more specific?)
Space Complexity - O(n) where n is the number of digits; using call stack + auxiliary array
Time Complexity - O ( n ) where n is the number of digits ( Is there a way to be more specific? ) Space Complexity - O ( n ) where n is the number of digits ; using call stack + auxiliary array
def super_digit(n)
  return n if n < 10
  sum_of_nums = n.to_s.split("").sum do |num|
    num.to_i
  end
  super_digit(sum_of_nums)
end
def super_digit ( n ) return n if n < 10 sum_of_nums = n . to_s . split ( "" ) . sum do | num | num . to_i end super_digit ( sum_of_nums ) end
Time Complexity - O(n) where n is the number of digits (Is there a way to be more specific?)
Time Complexity - O ( n ) where n is the number of digits ( Is there a way to be more specific? )
n
<not_specific>