Pergunta de entrevista da empresa Workday

During the phone interview, the coding question was done on a google doc and asked: In Java, given a String of [a-z] characters, find and return the first character that appears only once. I implemented it using a counting array and in the end the manager asked if I could implement it in another way, which I mentioned I could do it using a HashMap.

Respostas da entrevista

Sigiloso

11 de jun. de 2016

Prasad, your time complexity is O(n^2). It can be solved in O(n).

Sigiloso

11 de jun. de 2016

Also, you're using O(n) space while you can solve it with only O(1) space.

Sigiloso

7 de fev. de 2017

For(i in a to z) Count[i]=0 Index[i] = -1 For(j in 0 to len(string)) c = string.charAt(j) Count[c] += 1 If( index[c]==-1) index[c] = j Find count=1 and smallest index that is not -1

Sigiloso

3 de jun. de 2016

String input = "abcabcdedfek"; char result = 0; char[] ignoreArray = new char[input.length()]; int k=0; for (int i=0;i

1