## Pointer

BAN USER- 0of 0 votes

AnswersCan you think of a problem with the following singleton? If so, can you make it better and in the most efficient way?

- Pointer in United States for CMS

public class MySingelton {

private static volatile MySingelton mySingelton;

public static MySingelton getInstance() {

if (mySingelton == null) {

mySingelton = new MySingelton();

}

return mySingelton;

}

public static void main(String[] args) {

MySingelton s = MySingelton.getInstance();

...

}| Report Duplicate | Flag | PURGE

Micron Software Engineer Puzzle - 0of 0 votes

AnswersThe question inside the link.

- Pointer in United States for CMS

The pictures below contain a message in a secret code.

You will need to program to decode this message and to discover the password.

http://tsofen2015ms.azurewebsites.net/| Report Duplicate | Flag | PURGE

Micron Software Engineer Puzzle - 8of 8 votes

Answers1. qaz is a value for a number where this number is less than the other next values which have indexes larger than the index of this number.

- Pointer in United States for Autocomplete

for example: 33 , 25 , 26 , 58 , 41 , 59 -> qaz of (33) = 3 where 33 less than 3 numbers (58 , 41 , 59), qaz of (25) = 4 and not 5 because the index of 33 is less than the index of 25, qaz of (26) = 3 , qaz of (58) = 1 , qaz of (41) = 1 , qaz of (59) = 0.

the question is to find the max qaz.

it can be solved simply using 2 loops which takes time of O(n^2).

that's ok but how can we solve this problem in O(nlogn).

I have an approach and know the algorithm I got during the interview but it take a 40 of me to find it and write the code, but it was hard to think about it during the interview in that way.

I want to know if somebody can think and write the code in less than 20 minutes !!!| Report Duplicate | Flag | PURGE

Google Software Engineer / Developer

This can be helpful:

a recursive function which returns a TreeMap<Integer,Integer> where it contains the number and the qaz of this number.

this function divide each time the array into 2 sub-arrays and then merge them, iterate the left tree map and for each number , do a binary search to find the first larger number than this number the add to the value of this number -> rightTreeMap.size()-1-(the index of the number) and so on.

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

koosha.nejad -- send me a message to my email : geniucode@gmail.com

- Pointer January 29, 2015