Software Engineer Interview Questions | Glassdoor

# Software Engineer Interview Questions

Software engineers write programs to design and develop computer software. Interviews are highly technical, so come ready to work through coding problems and math brainteasers. The specific questions you are asked will depend on what type of programming position you are looking for. Try researching a specific software discipline such as web development, application development, or system development.

## Top Interview Questions

Sort: Relevance Popular Date

Oct 1, 2009

May 1, 2012

Jan 23, 2013

Jan 21, 2010

Mar 5, 2012

### Software Development Engineer In Test at Amazon was asked...

Dec 6, 2012

Aug 8, 2011
 Implement a function string balanceParanthesis(string s); which given a string s consisting of some parenthesis returns a string s1 in which parenthesis are balanced and differences between s and s1 are minimum. Eg - "(ab(xy)u)2)" -> "(ab(xy)u)2" ")))(((" -> "" 13 Answers Use O(n) time and O(1) space. def balanceParanthesis(str) : (bef, aft, left, right) = (0, 0, 0, 0) for i in str : if i == '(' : if right > 0 : bef += right right = 0 left += 1 elif i == ')' : if left > 0 : left -= 1 else : right += 1 if right > 0 : bef += right if left > 0 : aft = left return '(' * bef + str + ')' * aft All we need to do is to delete unnecessary parenthesis. every time we encounter a ')' which has no previous '(' to match with, delete. delete every '(' left when we finished reading the string s. Show More Responses string justify(string str) { string s1 = ""; int l = 0, i; for(i = 0; i 0) { l --; s1 += ')'; } else if(str[i] == '(') { s1 += '('; l++; } } for(i = 0; i < l; i++) s1 += ')'; return s1; } @xemoaya try print balanceParanthesis(")))((("): you solution is wrong!! --> ((()))((())) @hussein try cout ((())) well according to the given examples, this code would do good void balance(char *u) { int n=strlen(u); int i=n-1; //modified string length for(;i>=0;--i) { if(u[i]=='(') --n; else break; } //remove extra right braces int l=0; for(int i=0;i0;--l,pos++) { output[pos]=')'; } output[pos]='\0'; need to add extra ) at end how about simple balancing with an open count? close any that are unclosed. but before that run a round to delete leading ')' and trailing '(' which are be deemed unnecessary. well in the above code for(;i>=0;--i) { if(u[i]=='(') --n; else break; } part removes trailing '(' then ofcourse we are removing and extra ')' [ones not balanced by a '('] finally if there were more {remember that by our approach we can never have more ')'} '(' then we need to balance them with ')' that is what this part of the code does for(;l>0;--l,pos++) { output[pos]=')'; } output[pos]='\0'; this part compacts the string, so we can do convert it inplace, if a standard technique to delete certain parts of a string is to fill those parts with '\0' and then compact the string that is what this does int pos=0; for(int i=0;i 0: count -= 1 out += c else: out += c return out def parenBalance(s): return removeExtra(removeExtra(s,'(',')')[::-1], ')', '(')[::-1]

May 15, 2010