Ruby: Set of strings.
Leetcode: 869. Reordered Power of 2.\n\n\nRuby: Set of strings.\n\n1. Need to get an array of powers of two till 10**9.\n2. Convert these numbers to strings and
## Leetcode: 869. Reordered Power of 2.\n\n\n**Ruby: Set of strings.**\n\n1. Need to get an array of powers of two till `10**9`.\n2. Convert these numbers to strings and sort chars. Create a set from the array.\n3. Convert inpur to string sort chars join and check does in include in the set.\n\nLet\'s try.\n\nRuby code:\n```Ruby\n# Leetcode: 869. Reordered Power of 2.\n# https://leetcode.com/problems/reordered-power-of-2/\n# = = = = = = = = = = = = = =\n# Accepted.\n# Thanks God, Jesus Christ!\n# = = = = = = = = = = = = = =\n# Runtime: 82 ms, faster than 100.00% of Ruby online submissions for Reordered Power of 2.\n# Memory Usage: 210.9 MB, less than 100.00% of Ruby online submissions for Reordered Power of 2.\n# @param {Integer} n\n# @return {Boolean}\ndef reordered_power_of2(n)\n  require "set"\n  @two ||= get_powers_of_2()\n    .map{|x| x.to_s.chars.sort.join}.to_set\n  @two.include?(n.to_s.chars.sort.join)\nend\n\ndef get_powers_of_2()\n  answer = []\n  value = 1\n  border = 10**9 \n  while value <= border\n    answer.push value\n    value *= 2\n  end\n  answer\nend\n\n```\n
['Ordered Set', 'Ruby']