Panda Guru LogoPanda
Guru

Microsoft screening question

Round 1

Questions: Write a function: public String solution();
that returns a string made of digits for which the following calculate function returns the highest possible value:

import java.util.Arrays; public class Solution { public int calculate(String S) { int length = S.length(); if (length > 100) { return 0; } int[] count = new int[100]; for (int i = 0; i < length - 1; i++) { int num = Integer.parseInt(S.substring(i, i + 1)); count[num] = 1; } return Arrays.stream(count).sum(); } }

returned value | score
----------------+-------
>= 59 | 50
>= 64 | 55
>= 69 | 60
>= 74 | 65
>= 79 | 70
>= 84 | 75
>= 89 | 80
>= 94 | 90
>= 99 | 100

Do not modify the calculate method.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.