Microsoft| Phone | Integer to Roman
Anonymous User
715

I gave Microsoft Tech screen round for Engineering Manager position. First round with hiring manager followed by tech screening

Below were the questions

  • Previous experience followed by Why you made those career choices
  • Career Mistakes
  • Management questions (How many people you manage/leadership style etc)
  • Explain any 2 design patterns
  • Convert Integer to Roman.

This was my solution (I need to practice leetcode problems :( )

public static String toRoman(int num) {
        int[] bases = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        HashMap<Integer, String> map = new HashMap<>();
        StringBuilder result= new StringBuilder();

        map.put(1, "I");
        map.put(4, "IV");
        map.put(5, "V");
        map.put(9, "IX");
        map.put(10, "X");
        map.put(40, "XL");
        map.put(50, "L");
        map.put(90, "XC");
        map.put(100, "C");
        map.put(400, "CD");
        map.put(500, "D");
        map.put(900, "CM");
        map.put(1000, "M");


        for (int i : bases) {
            while (num >= i) {
                result.append(map.get(i));
                num -= i;
            }
        }
        return result.toString();

    }
Comments (0)