You are viewing a single comment's thread. Return to all comments →
My Java solution with o(n) time complexity and o(1) space complexity:
public static void decentNumber(int n) { int fives = n; while (fives % 3 != 0) { fives -= 5; } if (fives < 0) { System.out.println("-1"); } else { System.out.println("5".repeat(fives) + "3".repeat(n - fives)); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and The Beast
You are viewing a single comment's thread. Return to all comments →
My Java solution with o(n) time complexity and o(1) space complexity: