Bloomberg LP Interview Question for SDETs
- 2of 2 votes
There's a function that concatenates two strings and returns the length of the resultant string. When called upon a series of strings how do we minimize the cost of using this function. Let's say we have 3 strings, A= "abc", B="def", C = "gh".- Spectral July 07, 2015 in United States
Now cost of merging AB = 6 and cost of merging the resultant string with C is 8. Thus the total cost is 6 + 8 = 14. However, if we merge A and C, then the cost is 5 and then merge B with this, the cost is 8, so the total cost is 13.
Find an algorithm that minimizes the cost of adding such a series of strings.
| Report Duplicate | Flag | PURGE
Bloomberg LP SDET Algorithm
Open Chat in New Window