## Anonymous

BAN USERThere are a lot of issues that need to be addressed here.

1. Can we repeat numbers . I guess yes.

2. Say we select 1 and then 2 then what are the next possibilities. 1,2,3, 5,8 or the same 1,2,3,4,7 As 1 is the first number that was selected.

3. Also do the numbers need to be in increasing order?

If answer to 2 is 1,2,3,5,8 and numbers can be in any order. Then as a basic solution we can create arrays of possible numbers for each number and then permute in them . Combine the results as a set to get rid of any repetitions.

I think its about scalability.. the most appropriate answer here IMO will be to first ask the interviewer how the data is stored in file. How we can access data..After that if possible get row i and column i , swap...upto n. If we cannot access row and column like that. we need to do this in small fragments .. the question here is not only for swaps in O(n) i think its also about no of file operations.

- Anonymous September 18, 2012**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

Well there are a few clarifications needed -

- Anonymous November 20, 2012How big is the file?

Are the strings in file sorted?

Does "_" mean single character or multiple characters?

If big file and strings are not sorted and we are using this function a lot then it makes sense to make a suffix tree like structure.

If sorted then just need to reach that point using some variation of binary search.

If small file then maybe even using brute force way of searching may be benificial.