The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [interview-questions]

This tag is for questions that came up in an interview.

Filter by
Sorted by
Tagged with
36
votes
4answers
6k views

Rainfall challenge

About a year ago when I was applying to jobs for the first time, I had an interview at a company and they posed the following problem to me, which I preceded to bomb. A year later I actually came up ...
6
votes
1answer
1k views

Swap items of a linked list in pairs

Here is the source of the question: GitHub Given a singly linked list, swap the list items in pairs (reconnect the pointers, not simply swap the values). For example: Before: A->B->C->D ...
22
votes
4answers
3k views

Determining if an answer can be generated

How can I improve my code below for the following question? While it works, I am not satisfied with how it looks; I was hoping I can somehow keep it recursive, and have the ans filled up inside the ...
20
votes
4answers
2k views

Finding the sub-array with the maximum sum - my approach

This is the code I ended up with that implements the approach I described in a recent answer to another question about the same problem The basic idea here is to not loop through more things than ...
3
votes
1answer
146 views

Swap items of a linked list in pairs - revision 2

The first revision is available here and the code is available on GitHub. I modified the method reversePairs and added mSize to ...
2
votes
1answer
73 views

Swap items of a linked list in pairs - revision 3

Here is the source of the question. Revision 1. Revision 2. When I started the second round of code review, I wanted to make sure that I had included all the possible input types. However, I ...
203
votes
4answers
21k views

Calculate SHA1 hash from binary and verify with a provided hash

I applied for a job and they asked me to write code with the following requirements: Get a "toolbar offer" description from http..update.utorrent.com/installoffer.php?offer=conduit. Parse the ...
54
votes
11answers
12k views

Sales tax calculator, rejected for being not OOP

I applied for an Application Developer position. They require all their applicants to complete 1 of 3 programming assignments. I picked one for sales tax calculation. It was quite simple. Write ...
38
votes
5answers
24k views

Designing a coffee machine

I was recently rejected from what looked like a really promising string of interviews. I did very well in a questionnaire style review, and then they handed me this assignment (more or less): ...
37
votes
10answers
7k views

Which FizzBuzz is better, and why?

I was in an interview and the guy asked me to do the typical FizzBuzz question of printing numbers 1-100, but for each factor of 3 print Fizz, each factor of 5 print Buzz, and each factor of both ...
10
votes
2answers
2k views

Missing level of technical depth (Common Ancestor)

I recently have given a coding test in a reputable IT company. There were three coding questions. They refused me by saying that as we felt they didn't demonstrate the level of technical depth we'...
3
votes
5answers
3k views

Validate that brackets are balanced

I've done a test for a job (which I failed) and I'd like to know in which ways my code could've been better. Here are the questions and my answers, it's not very long. 1) Make a program that ...
19
votes
3answers
3k views

Reversing k-sized sequences in a linked-list

Here is my solution to this problem; please be brutally honest/strict, if I would have written this code, in a 45 minute interview, what would you think? (I am aiming for Google,Facebook). Here is ...
6
votes
1answer
1k views

Missing level of technical depth (Recursive to Iterative)

I recently have given a coding test in a reputable IT company. There were three coding questions. They refused me by saying that as we felt they didn't demonstrate the level of technical depth we'...
6
votes
3answers
2k views

Missing level of technical depth (Flatten Tree)

I recently have given a coding test in a reputable IT company. There were three coding questions. They refused me by saying that as we felt they didn't demonstrate the level of technical depth we'...
7
votes
1answer
611 views

Are AVL trees equal?

I was inspired by this answer and decided to implement an AVL tree with the methods equals and hashCode as if I was asked to do ...
6
votes
5answers
759 views

DP solution to min triangle path

I am studying for interviews for various companies. I wrote a solution to this problem, but if an experience programmer looks at it I am sure there are certain areas the code can be made in to a more ...
4
votes
1answer
412 views

Improving time complexity of finding the longest palindrome in Python

The Longest Palindromic Substring challenge from InterviewBit: Given a string S, find the longest palindromic substring in S. where a "substring" must be contiguous, and in case of ties the first ...
2
votes
3answers
2k views

Find all triplets in array that add up to a given sum

Given an array and a value, find all the triplets in the array whose sum is equal to the given value. For example, if the given array is {12, 3, 4, 1, 6, 9} and the ...
1
vote
1answer
86 views

Swap items of a linked list in pairs - revision 4

Here is the source of the question. The solution on GitHub. Revision 1. Revision 2. Revision 3. @200_success' suggestions from revision 3: The iterator's ...
90
votes
16answers
8k views

Outputting the names of cars, without repetitions, with the number of occurrences in order of decreasing repetitions

A short while ago, I have submitted a coding exercise to a potential employer. The response came back the next morning and you can guess what it was from the subject of this post. I am not ...
142
votes
17answers
27k views

Searching an element in a sorted array

I was applying for a position, and they asked me to complete a coding problem for them. I did so and submitted it, but I later found out I was rejected from the position. Anyways, I have an eclectic ...
28
votes
8answers
46k views

Find all the missing number(s)

Recently I've attended an interview, where I faced the below question: Question: "There is an sorted array. You need to find all the missing numbers. Write the complete code, without using any ...
22
votes
7answers
5k views

Sales Tax Problem, rejected for not being up to their standards

I applied for a Junior .NET Developer Position recently, and I was asked to solve a problem (Sales Tax Program) and I was rejected for some reason. The question goes like this: Basic sales tax is ...
16
votes
4answers
73k views

FizzBuzz implementation

The common FizzBuzz implementation I saw is using a check for % 15 for printing "FizzBuzz" Would you let me know if there is anything wrong / better with this approach? ...
8
votes
3answers
1k views

Reorder a list of courses, given their prerequisites

I recently graduated from college and applied for a position with a company. I was sent a coding exercise as part of the process. After completing the exercise and submitting it I was told that the ...
12
votes
10answers
6k views

Tests for palindromes in C and C++

A question I've been asked on interactive phone screens is to code a test to determine whether a string is a palindrome or not. I am providing two examples here: one in C and one in C++. They both ...
12
votes
3answers
731 views

Reversing a linked list

I implemented reversing a linked list in iterative way, just by knowing we need 3 pointers and I have never seen a code before, when I coded. I ran this code and tested it, it works fine. Even for ...
12
votes
3answers
12k views

Counting permutations without repetitions for a number or a string

Can I make the following code faster with minor modifications? It times out on CodeWars website. ...
19
votes
2answers
4k views

Designing another Coffee Machine Application

After reading Designing a coffee machine yesterday, I decided I could also give the same problem a try. I have used the following problem statement (copied from the given question): Design a ...
9
votes
2answers
11k views

Add one to a number represented as an array of digits

I submitted this problem for an interview, and I was wondering if I could have done better. My solution works, and I solved in about 12-15 minutes. I feel like I did a bad job with the code. Please ...
8
votes
4answers
15k views

Find the subarray with the max sum

In an interview I was asked to solve the following problem: find a subarray with max sum I have written a piece of code for the same. I need your help in reviewing this code. ...
23
votes
3answers
6k views

Java Inventory System

I'm often applying to jobs just to test out my skills. I have recently applied to one, had to submit a Java problem, but got rejected. Could someone please review my application briefly and tell me ...
14
votes
1answer
9k views

Printing a Binary Tree top-down (column wise)

We have a binary tree, suppose like this: 8 / \ 6 10 / \ / \ 4 7 9 12 / \ 3 5 We have to print this binary tree in top-down ...
13
votes
1answer
982 views

Interview coding challenge for iOS Part 2 - the application in Objective-C and Swift

I recently interviewed with a company that needed a C/C++ programmer to work on the iOS side of the products. The job description indicated they needed someone with 4 years of Objective-C and iOS ...
12
votes
7answers
27k views

Given an array of integers, return all pairs that add up to 100

I was recently given this programming challenge on an interview, and I decided to use javascript to solve it. I did, but I'm not happy with my implementation. I can't help thinking there must be a ...
12
votes
1answer
834 views

Find the peak stock price for each company from CSV data

During the hiring process, a company gave me this test: Q) Consider Share prices for a N number of companies given for each month since year 1990 in a CSV file. Format of the file is as below with ...
10
votes
2answers
228 views

Python implementation of find_all_indexes

I got asked this question before in an interview. For example, find_all_indexes('ababc', 'abc') returns 2. This Python function ...
9
votes
2answers
3k views

Fizz Buzz interview question code

Reading Jeff Atwood's "Why Can't Programmers.. Program?" led me to think that almost all of the solutions would not be something I would want in my own code-base. The Fizz Buzz program specification ...
9
votes
5answers
1k views

Find first non-repetitive char in a string

I just had an interview for the C#.NET developer position and I was asked to find the first non repetitive char in a given string without using any library functions but just the basic constructs of ...
7
votes
2answers
978 views

Reversing a domain name string in Java

Given a dot separated domain name, reverse the domain elements. Example: ...
7
votes
3answers
2k views

Elevator Interview Problem OOP - Revised

Elevator program code challenge, revised: Can someone please critique my Elevator problem - I wanted to use OOP principles and coding standards. Also, does logic make sense? ...
5
votes
2answers
1k views

Project Euler problem 79: deducing a passcode

For one place that I interviewed at (for a Python developer position) I worked with one of the devs on two Project Euler problems, one being problem 79. We talked through different approaches and came ...
5
votes
4answers
3k views

Expense-sharing calculation

Friends A, B, C, D go for a trip. They spend on various expenses. Cost of the expense is shared. Example : A spends 100 for breakfast for A, B, C and D D spends 500 for cab for B and C B spends 300 ...
3
votes
6answers
2k views

Blackjack game interview task

As part of a recent interview, I was assigned to write a small BlackJack program. After submitting the solution, I received an answer that "the solution was functionally OK, but was way below their ...
17
votes
2answers
930 views

Given a page of content, determine shortest snippet containing all search phrases (no order required)

A recruiter gave me a homework problem as a part of the recruiting process and after receiving my submission he told me that he decided not to proceed with me. When I asked for the reason, he told me ...
15
votes
4answers
1k views

Number to words in left to right direction

I have faced this question in an interview: If we enter a number it will convert into individual strings and display in same order. Ex: If I enter 564 then ...
9
votes
2answers
34k views

Evaluating an expression with integers, +, and *, as well as -, /

There is a job interview question, and the source of the question is here. The solution is pretty simple. We just need to split the input string by + and then by *. Then we compute products in a ...
8
votes
3answers
5k views

Approximate String Matching Interview Question

I was working on the challenge Save Humanity from Interviewstreet for a while then gave up, solved a few other challenges, and have come back to it again. The code below generates the correct ...
8
votes
3answers
13k views

Printing an hourglass pattern

In a recent interview I have been asked to write a program to generate the following output: ...