package leetcode;

/**
 * https://leetcode.com/problems/hexspeak/
 */
public class Problem1271 {
    public String toHexspeak(String num) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1271 prob = new Problem1271();
        System.out.println(prob.toHexspeak("257")); // "IOI"
        System.out.println(prob.toHexspeak("3")); // "ERROR"
    }
}

@@ -145,256 +145,314 @@
     
-// TODO%0A        return null
+String hex = Long.toHexString(Long.valueOf(num)).toUpperCase()%0A            .replaceAll(%220%22, %22O%22).replaceAll(%221%22, %22I%22)
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1271 prob = new Problem1271();%0A        System.out.println(prob.toHexspeak(%22257%22)); // %22IOI%22%0A        System.out.println(prob.toHexspeak(%223%22)); // %22ERROR%22
+for (int i = 0; i %3C hex.length(); i++) %7B%0A            if (hex.charAt(i) %3E= '2' && hex.charAt(i) %3C '9') %7B%0A                return %22ERROR%22;%0A            %7D%0A        %7D%0A        return hex;
 %0A   

Solve problem 1271