London, England interview questions | Glassdoor.co.uk

# Interview questions in London, England

Bloomberg L.P. Interviews in London

www.bloomberg.com /  HQ: New York, NY

807 Interviews in London (of 4,525)

3.1 Average

PwC Interviews in London

www.pwc.com /  HQ: New York, NY

456 Interviews in London (of 7,390)

3.1 Average

Accenture Interviews in London

www.accenture.com /  HQ: Dublin

437 Interviews in London (of 10,136)

3.0 Average

## Interview Questions in London

Sort: RelevancePopular Date

27 Apr 2011

29 Dec 2012
 We consider numbers from 1 to 1 million. How many digits 2 are there??10 Answers600 000940951654321: The total number of digits 1-999,999 is 5888889 Total 1-9 = 9 10-99 = 2*9*10 and so on so number of 2s is 5888889/9Show more responses654321: The total number of digits 1-999,999 is 5888889 Total 1-9 = 9 10-99 = 2*9*10 and so on so number of 2s is 5888889/9Each time you fix a digit 2 (in units, tens...), then you change the other 5 digits. So you'll have 100 000 number. Having that for the six placements, the result would be 600 000.600,000 6C6 with 6 digits, 9(6C5) with 5, (9^2)(6C4) with 4...etc. Add them up 600,000.11111110^6-9^6observe the recurrence relation. 1-9 there is 1 from 1-99 there is 10 1-9 intervals plus 10 digits from 2x. and then it continuous in exactly the same fashion add one 0 you get 10 times as many plus 10^(n-1) from the nth digit you add. (((((10+10)*10+100)*10+1,000)*10+10,000)*10+100,000)=600,000Consider from 0000000 to 9999999, the number of 0,1,2,3,4,5,6,7,8,9 present must be the same since they are all symmetric. prove: the position can be filled with 0 can be filled with 1, so the number of 0=the number of 1; the number of 1=the number of 2 for the same reason. ... so the number of 0-9 are all the same. There are 6*1million positions in total, thus 6 million positions, divided by 10, is 600,000.

2 Jan 2011
 You roll two die: What is the probability of rolling a 10 and an 11 before rolling a 7?8 Answers17/132How did you get that?Individually 10 comes up 3/11 (4+6, 5+5, 6+4), 11 comes up 2/11, 7 comes up 6/11. Consider 10 first: Then only interested in 7,11: Probability 11 is 2/8, 7 is 6/8. Consider 11 first: Then only interested in 7,10: Probability 10 is 3/9, 7 is 6/9. Consider 7 first: Busted. So add 10 then 11, and 11 then 10: (3/11)*(2/8)+(2/11)*(3/99)=17/132.Show more responses5/11 let's say d is the probability that 10 or 11 comes up before 7. probability of rolling 10: (6+4,4+6,5+5) = 3/36 probability of rolling 11: (6+5,5+6): 2/36 probability of rolling 7: (6+1,1+6,5+2,2+5,4+3,3+4): 6/36 d = you roll 10 or you roll 11 or (you roll something other than 10,11,7 and roll 10 or 11 before 7) d = (3/36) + (2/36) + (25/36)*d (11/36)*d = (5/36) d= 5/11Anonbyfar is correct, 5/11 is the right answer but for the wrong questiondoesnt the answer by 'Anonbyfar' (17/132) give you the probability of rolling a 10 and 11 within two rolls? Shouldnt this be then related to the probability of rolling a 7 (6/11). I.e 17/72?P(10 or 11 before 7) = P(10 or 11 | 10 or 11 or 7) = [P(10) + P(11)]/[P(10)+P(11)+P(7)] P(10) = 3/36 4,6 5,5 6,4 P(11)= 2/36 5,6 6,5 P(7) = 6/36 1,6 2,5, 3,4 4,3 5,2 6,1 Answer: 5/11roll 10 or 11: 5 cases roll 7: 6 cases roll others: 25 in total: 36 cases So Pr = 5/36 + 25/36 *Pr Pr = 5/11

6 Oct 2013
 If I write down all of the numbers from 1 to 1,000,000 on a page, how many times do I write down the digit 2?9 Answers(base 10 )log(x)/10*xI got 468599600000 (verified through brute force)Show more responsesimagine the numbers written as 000001 000002 000003.....999998 999999, then we 1 million numbers containing 6 digits, each digit of 10 digits we have, is used as much as any other number. Therefore, you write down the digit 2 10% * 6 million - 600,000the minus must be an equal sign on the end, so 600,000 is the right number[1 x 10 x 10 x 10 x 10 x 10] + [10 x 1 x 10 x 10 x 10 x 10] - 1 + (bcos 222222 covered above) [10 x 10 x 1 x 10 x 10 x 10] - 2 + (bcos 222222 & 22222 covered) [10 x 10 x 10 x 1 x 10 x 10] - 3 [10 x 10 x 10 x 10 x 1 x 10] - 4 [10 x 10 x 10 x 10 x 10 x 1] - 5 = 600000 - 15 = 599985Continuation from above from 1 upto 1 with n 'zeros' (e.g. 10 has 1 zero, 100 has 2 zero, etc), answer = n(10^[n-1]) - 0.5n(n-1) So upto 1000000 would give 6 x 10 ^ 5 - 0.5 x 6 x 5 = 599985The idea is to exploit the symmetry among 0,1,2...9. Instead of 1->10^6, one should think of 000000 -> 999999, where 0-9 occurs with the same probablity . Altogether 000000 -> 999999 has 10^6 numbers, 6*10^6 digits; divided by 10 this is 600,000.The idea is recursion, let x_n be number of times that digit 2 appear in 0 to the largest n digit number. For example, x_1 = number of times that 2 appears in 0-9. x_2 is up until 99, etc. you work out to see x_1 = 1. x_2 = 10*x_1 + 10 etc. finally, I think you will get 600000

### Assista at Jane Street was asked...

14 May 2012
 2nd Round: You have a deck of cards, 26 red, 26 black. These are turned over, and at any point you may stop and exclaim "The next card is red.". If the next card is red you win £10. What's the optimal strategy? Prove this is the optimal strategy.6 AnswersThe simplest strategy is not to wait until any card is open and say the next one is red, than you have 26/52 chance of success. All other strategies require conditional probabilities, so when multiplying by the probability of that condition the overall probability is not going to be greater than 1/2.Regardless of your strategy, your probability of winning is 1/2Nope the optimal strategy is to count the amount of black cards that come up until you hit 26 and obviously the next one is redShow more responsesAdrian is wrong, because the strategy only work 50% of the time, when the last card is not black. So you still get 1/2.The idea here is A LEAP OF FAITH: that is we have found the optimal strategy when there is X red and Y black left in the deck. let Strategy(X,Y) be that strategy: it is either "Wait" or "Say it now". Let P(X,Y) be the probability that we are right by following this strategy. now Strategy(X, 0) is definitely "say it now" and P(X, 0) = 1. what about Strategy(1, 1)? half the time it will show black and we win for sure; half the time it will show red and we are doomed. Both action, "wait" and "say it now" have the same expected chance of winning, which is 1/2. so P(1,1) = 1/2. What about Strategy(2, 1)? if it is "wait", 2/3 time we go to (1, 1) and 1/3 time we go (2, 0). the chance of winning if we wait is 2/3*1/2 + 1/3*1 = 2/3. if it "say it now", the chance of winning is 2/3 as well. so P(2, 1) = 2/3. As you can see, we basically have the following relationships: P(X, 0) =1 for any X. P(X, Y) = max( X/(X+Y), X/(X+Y) * P(X-1,Y) + Y/(X+Y) * P(X, Y-1)) and you can probably guess that P(X, Y) = X/(X+Y) so P(26, 26) = 1/2. That means calling out on first card or wait both gives you optimal strategy.always 1/2

### Analyst at J.P. Morgan was asked...

3 Apr 2011
 puzzle 9 balls, identical in appearance. 8 are of same weight. 1 is heavier. Identify this heavier ball by using a scale twice.5 Answersput 9 balls in groups of 3.Split them into two sets of 4 and 1 individual ball. Place the two sets on each side of the balance. If the sets balance out, then the individual ball is the heavier one. If the sets don't balance, then take the heavier set and split it up into two sets of two and repeat.I believe that an explanation to the solution that Interview Candidate is suggesting can be found here: http://brainteaserbible.com/snooker-balls-weighing-scalesShow more responsesSplit the balls into groups of three, compare two of the groups. If the sets balance then the heavy ball is in the third group, otherwise it is in the group left out. Whichever it is, take two balls from that group to weigh. If they balance, you know it is the third ball, if they don't, you have the heavier ball.http://brainteaserbible.com/snooker-balls-weighing-scales

### Financial Software Developer at Bloomberg L.P. was asked...

4 Dec 2009
 write a function that returns the first unique element in an array5 AnswersWhat the type of elements in the array? If character, set up the hash table, and scan the array. the hash table stores the index of each element. If the element appears more than once, update the table as a negetive value. After scanning, find the smallest index value from the hash table, which would be the first uniqure element. The time complex gonna be O(n), where n is the length of array.I wrote a sample program here. (I use map container here to replace hash_map. The doesnot work on my computer) #include "stdafx.h" #include #include using namespace std; static int find_unique_ele(char*,int); int _tmain(int argc, _TCHAR* argv[]) { char test[6] = {'a','b','c','b','c','a'}; int min_index = find_unique_ele(test,6); if (min_index store_table_value; map store_table; while(i ::const_iterator test_it = store_table.find(*test); if(test_it != store_table.end()){ store_table[*test] = -1; } else{ store_table.insert(map::value_type(store_table_value(*test,i))); } i++; test++; } map::const_iterator table_it = store_table.begin(); store_table_value temp_value = *table_it; int min_index = temp_value.second; while(++table_it != store_table.end()){ temp_value = *table_it; if(temp_value.second < min_index || min_index < 0){ min_index = temp_value.second; } } return min_index; }I think in the above solution you have to scan the original array twice making it order (2n) or O(n). The 2nd scan is needed to determine the corresponding entry in the hash table whether it is unique or not. We need this to determine the first unique element in the array.Show more responsesSort the list then scan the list looking for a data item that does not match the previous item or the next item.very easy with c++ stl using unique() function or use hashtable for O(1) look -up HashTable mm = new HashTable(myArray.count()); for(int i =0; i

25 Apr 2013
 The questions were not very difficult but you really need to have all the concepts crystal-clear and be ready to apply them successfully. One of the questions was "how to count the letters in this string:" "The quick brown fox jumps over the lazy dog";11 Answerspublic static int countWords(String str){ if(str == null || str.isEmpty()) return 0; int count = 0; for(int e = 0; e < str.length(); e++){ if(str.charAt(e) != ' '){ count++; while(str.charAt(e) != ' ' && e < str.length()-1){ e++; } }else{ e++; } } return count; }Sorry, the above version has an error!!!!!!!!!!!!!!!!!!!!!!!! concider this one: public static int countWords(String str){ if(str == null || str.isEmpty()) return 0; int count = 0; for(int e = 0; e < str.length(); e++){ if(str.charAt(e) != ' '){ count++; while(str.charAt(e) != ' ' && e < str.length()-1){ e++; } } } return count; }# That's why i love Python: len(re.findall('[a-zA-Z]', s))Show more responsessorry u need to give input ;) ------ len(re.findall('[a-zA-Z]', "The quick brown fox jumps over the lazy dog"))It depends on what has to be considered a word. For example, if we consider a word any string between spaces, we can write it in a more compact way: public static int countWords(String str){ if(str == null || str.isEmpty()) return 0; return str.split(" ").length; }The question is how to count the characters in the string. If we can assume that the input is ASCII - always clarify first - then we know that the character range is 0-255. void count(char* str, int counts[255]) { if (str == 0) return; if (counts == 0) return; for (char *c = str; c != 0; c++) { counts[*c]++; } } First we assert the input is valid. Note that we take an additional parameter - an array of the count of each ASCII character. We loop through the string until we reach the null terminator, and we iterate a char pointer through each character in the string. For each iteration, we increment the counter in the array. Memory complexity is O(1), runtime complexity is O(n). If the input must be unicode, then we may consider alternatively using a hash table. void count(wchar_t* str, std::unordered_map& counts) { if (str == 0) return; for (char *c = str; c != 0; c++) { counts[*c]++; } } We still arrive at an O(1) memory complexity and O(n) runtime complexity (although it is worth noting that despite a hash table lookup takes O(1) like an array, the fixed cost of each lookup is higher for the hash table due to the hashing function, and in the worst case a lookup can be O(n)).The question asks to count the characters, without using String.length() you can do this: public static Pair countLetters(String s) { //If the string is null or it is empty then it will have no character if (s == null || s.isEmpty()) { //So return the pair with 0 and 0 return new Pair(0, 0); } //If we should still run the loop. boolean run = true; //The count of characters int count = 0; //The count of characters without spaces int countWithoutSpace = 0; //While we are still running (we are at a valid index) while (run) { //Then try to try { //Get the character at the current count char c = s.charAt(count); //Add one to the count as we have a valid character count++; //If the character is not a space if (c != ' ') { //Then add one to the count without spaces. countWithoutSpace++; } //If we get a StringIndexOutOfBooundsException it means that the current count is outside the length of the string. } catch (StringIndexOutOfBoundsException e) { //So stop the loop. run = false; } } //And return the pair with the count and the count without spaces. return new Pair(count, countWithoutSpace); } This returns both the count with and without spaces and does not use a built in length function.Wait..Am I missing something? string.Length will do the job?Yeah i think string.length() will do the job.failed! String.length returns the length of the String. Google asked you how many letters - in other words you cannot count the spaces. String. length returns number of unicode characters -and so includes spacesI would do this: public static int countWords(String sentence){ String noSpace; //REMOVE SPACE noSpace = sentence.replaceAll(" ", ""); return noSpace.length }