---
# System prepended metadata

title: Untitled

---

```
package main

import (
  "strconv"
  "math"
  "sort"
)
// Solution is your solution code.
func Solution (a int) int {
  // Your code starts here.
  if a > 11 { // O(1)
    numbers := breakdownNumber(a) // timecomplexity O(n)
    sort.Slice(numbers, func(i, j int) bool { // timecomplexity O(n Log n)
      return numbers[i] > numbers[j]
    })

    number := convertToSingleNumber(numbers) // timecomplexity O(n)
    if number > a { // O(1)
      return number
    }
  }
  
  return -1
}

func convertToSingleNumber(numbers []int) int {
  digit := len(numbers)-1
  number := 0
  for _, n := range numbers {
    tmp := n * int(math.Pow(10, float64(digit)))
    number += tmp
    digit--
  }

  return number
}

func breakdownNumber(a int) []int {
  result := strconv.Itoa(a)
  runes := []rune(result)
  numbers := []int{}
  for _, char := range runes {
    num, _ := strconv.Atoi(string(char))
    numbers = append(numbers, int(num))
  }

  return numbers
}