Senior Software Engineer Interview Questions | Glassdoor.co.uk

Senior Software Engineer Interview Questions

658

Senior software engineer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Implement a method called printNonComments() which prints out a extract of text with comments removed. For example, the input: hello /* this is a multi line comment */ all Should produce: hello all You have access to a method called getNextLine() which returns the next line in the input string.

5 Answers

// NOTE: Not tested on an editor, may not compile. Think as a pseudo code // There is condition where this code fails: If there are two comments on the same line like // some text /* hi there */ some more and /* another comment */ even more text public static void main(String[] args){ final String COMMENT_START = "/*"; final String COMMENT_END = "*/"; bool isCommentStarted = false; String line = getNextLine(); while(line != null && line.length() >0){ int index = line.indexOf(COMMENT_START); if(index != -1 && isCommentStarted == false){ // print up until the comment System.out.print(line.subString(0, index)); isCommentStarted = true; } index = line.indexOf(COMMENT_END); if(index != -1){ // print what we have after the comment end System.out.print(line.subString(index)); isCommentStarted = false; } line = getNextLine(); System.out.println(""); // write on next line } }

//need to use and also "/*" and "*/" need to be followed by space " ". int main() { string s = "hello /* this is a multi line comment */ all "; istringstream iss(s); string tmp; while(iss>>tmp){ if(tmp=="/*"){ while(iss>>tmp){ if(tmp=="*/"){ iss>>tmp; break; } } } cout<

def echo(what): sys.stdout.write(what) def gobble(what): pass funsrc = cycle([(echo, "/*"), (gobble, "*/")]) consumer_fun, delim = funsrc.next() while True: line = getNextLine() if not line: break ix = line.find(delim) while ix >= 0: prefix = line[:ix] line = line[ix+len(delim):] consumer_fun(prefix) consumer_fun, delim = funsrc.next() ix = line.find(delim) consumer_fun(line)

Except experience related questions I was asked coding question and I was supposed to write the solution to the problem in any programming language in a simple web-based code editor. The question was: given and array of positive integers and another integer find whether there is a consecutive range in the array, so that the sum of integers in the range is equal to the given number. They put an emphasis on delivering working, efficient solution. In my opinion this kind of interview requires a thorough preparation.

5 Answers

Find Kth minimum node in a binary tree and suggest a complexity

5 Answers

Received solution for refactoring.

3 Answers

How will you prevent the code in finally block from executing? The question isn't a very fair one as a good programmer would not write the code in finally block that he/she doesn't want to execute

3 Answers

Did not go through the interview process.

2 Answers

you are given a dictionary which contains words hat mat cat hot pot. starting word is hat and ending word is pot you need to find out shortest path..by changing only one character at a time

2 Answers

All questions around multithreading.

2 Answers

General questions about C++, templates, some logic based riddles. i.e. Using just a single weight scale and having 9 marbles of equal mass apart from one, which is heavier, how many times do you need to use the weight scale to find the heavier marble?

2 Answers

Write an algorithm to rotate a node of a binary tree.

2 Answers
110 of 658 Interview Questions