Vistaprint Interview Question: Choose a data structure to st... | Glassdoor

Interview Question

Software Engineer Interview(Student Candidate) Lexington, MA

Choose a data structure to store the extracted words and

  their positions in a sentence and then bring the sentence back using any language you like. Writing code on paper.

Interview Answer

2 Answers



Interview Candidate on Nov 3, 2011

Keep it in a dictionary (python) or a hashmap (java) >

TO bring sentence back
1) find the max location in the dictionary.
 Size of entire string = location + size of the word
2) Create new char array new_blank_array[Size of entire string]
3) traverse the dictionary and place the words as per their respective place.

Complexity : O(n)

Jayanth on Oct 22, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.