Data structures Interview Questions | Glassdoor

# Data structures Interview Questions

116

interview questions shared by candidates

## Data structures Interview Questions

### Special Education Paraprofessional at Denver Public Schools was asked...

May 19, 2016
 What is a situation in which you have been challenged by a student and how did you meet that challenge and learn from it for future lessons2 AnswersI talked about a student with autism I had that used to spit on me and other paras every time we tried to get him to learn and do work. I explained the many tactics we came up with and tried as a team and the many ways I tried on my own to get his behavior to change. Until we finally came up with a tactic of reward and recoil that got him away from spiting and excited to do work.I had a student who would keep talking even when she wasn’t supposed to. I tried changing her seat frequently, talking to her parents then finally settled on having her take a paper and write out what’s on her mind in the back of the room which seemed most effective. I also found that letting her help with tasks worked

Dec 10, 2014

### Senior Software Engineer at Apple was asked...

Nov 24, 2014
 Given a string of words and a maxWidth, write a method that inserts new lines where appropriate to perform a word-wrap. (Wrap on word boundaries, assume " " is fine). Now, how does your implementation handle string with multiple spaces between words ... Are those extra spaces lost or preserved?2 AnswersStringBuilder str = new StringBuilder("This is a very long string which has to be converted"); int maxWidth = 10; int length = str.length(); int currentWidth = maxWidth; while( currentWidth < length && str.lastIndexOf(" ",currentWidth) != -1) // last word will not have white space at end so this second check is needed { int spacePoint = str.lastIndexOf(" ",currentWidth); str.replace(spacePoint, spacePoint+1, "\n"); currentWidth = spacePoint + 1 + 10; // start the next substring from space+1th point + 10 chars System.out.println("i = " + currentWidth); } System.out.println(str);This is a DP problem

### Senior Software Engineer at Apple was asked...

Nov 24, 2014
 Given a histogram data representation, how would you find the adjacent bars/columns that collectively yield a rectangle with the largest coverage area.1 Answertake each pair of adjacent bars(histogram buckets) and compute:- min(adjacent pair of bars ) * no values with that range(buckets). Then the bars corresponding to max value is the answer

Nov 17, 2014
 Write a function that given a sequence and a number b between [-10,10] return a new sequence. Sequences are generated by this: http://en.wikipedia.org/wiki/Look-and-say_sequence a number b if equal to 0 the function will return the input sequence Valid sequences: 1 11 21 1211 111221 ... Example: input: 1211, +1 output: 111221 Example: input: 111221, -1 output: 12113 AnswersUsed recursion to generate sequences. Should be an iterative way to do the generation, but I was able to figure it out during the interview.See this problem on LeetCode: https://oj.leetcode.com/problems/count-and-say/static String look_and_Say_add_1(String num){ if(num==null) return null; StringBuilder sb = new StringBuilder(); char repeat = num.charAt(0); num = num.substring(1) + " "; int times = 1; for(char current: num.toCharArray()){ if(current==repeat){ times++; } else{ sb.append(times+""+repeat); times = 1; repeat = current; } } return sb.toString(); }

Nov 17, 2014
 main() { A() C() } A() { B() } B() {} C() {} input: t1 main enter t2 A enter t3 B enter t4 B exit t5 A exit t6 C enter t7 C exit t8 main exit output: main (t8-t1) A (t5-t2) B (t4-t3) C (t7-t6) Write a function that given the input will create the output1 AnswerI used a stack to solve the duration of functions, but wasnt able to solve how to do the indentation during the interview

Oct 29, 2014
 All the questions were from data structures, algorithms, and programming1 AnswerCan you post any questions you were asked?

### Senior Software Engineer at Yahoo was asked...

Jul 8, 2014
 Given a binary min heap, insert a new member.Be the first to answer this question

### Software Engineer Entry Level at ShopRunner was asked...

Jun 22, 2014
 Hash table lookup.1 Answer+1 for hash tables

### Technical Analyst? at Molina Healthcare was asked...

May 16, 2014
 Given a website with static html pages and a list of words to censor, mark all pages that have a censored word. What is the best O-notation you can come up with?Be the first to answer this question
110 of 116 Interview Questions