Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [interview-questions]

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

Filter by
Sorted by
Tagged with
10
votes
4answers
14k views

Counting occurrences of each word in a sentence

I have been doing this test task for C# Developer role at UBS.London recently and have been rejected. No reason stated yet. Was wondering if you can take a look and provide feedback on what I can do ...
10
votes
2answers
3k views

xml is XML is xml is XML

I had to write some code for an interview, to print out the name attribute of each node. I started off going in the wrong direction, so I didn't get to finish. I wanted to finish writing the code, so ...
10
votes
3answers
3k views

Linked list loop detection in Java

A schoolmate is going through the interview process, and was given the question of detecting if a linked list data structure has an infinite loop in it. I wrote this example, and wanted to see what ...
10
votes
2answers
999 views

Animal choir simulator

I got a PHP developer interview test to solve for a company. I didn't get the job but I would like to know where I was wrong. Did I understand the test completely? ...
10
votes
2answers
4k views

Fish Food Chain of complexity O(N)

I understand that if you don't know the trick, it's not easy create a solution with a complexity of \$O(N)\$. However, I would like to ask you how to solve this tricky question: You are given two ...
10
votes
4answers
1k views

Determine if an array is the reverse of a second array

I tried to do it by using ArrayUtils.reverse() but I couldn't figure out how to compare this with the other array. So I wrote this instead: ...
10
votes
3answers
2k views

Find two unique integers in sorted array

I have to write the following method: I have sorted array of integers and in this array every integer repeats twice, except two elements. I have to find these two elements. Input: 1, 1, 2, 3, 3, 4, ...
10
votes
3answers
5k views

Vertically print a list of strings to STDOUT into 3 columns with column lengths as balanced as possible

This was a interview question I struggled with, I am posting my solution hoping to look for more elegant/efficient solutions. Problem: Given a list of strings, print its element out to STDOUT one by ...
10
votes
2answers
229 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 ...
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'...
10
votes
1answer
161 views

Merging JSON and inserting into the DOM

I'm an aspiring junior dev. This is modified version of the code I wrote for a technical interview I did today (Didn't pass. Sad.). The problem was to fetch two json files, and display their data on a ...
9
votes
5answers
15k views

Python code to check if an array has a sequence (1,3,4)

I recently applied for a job as a Python coder but was rejected. This was the problem: Write a python code to check if an array has a sequence (1,3,4) Assuming they were looking for expert Python ...
9
votes
5answers
13k views

Find missing number from list

I was asked a question in an interview the other day: You have an array list of numbers from 1 to 100, the problem is that one number is missing. How would you find that number? This is a mock ...
9
votes
5answers
50k views

Count the number of occurrences of a word

I was selected for the third round of MS internships for third years. We were surprisingly asked a very easy question: “Make a program that counts the number of times the WORD "a" or "A" occurs”. I ...
9
votes
4answers
14k views

Finding overlapping time intervals

You have two lists with meetings scheduling (start time, end time). Meetings in single list don't intersect. Find all intersecting meetings across the two lists. Is my complexity \$O(N M)\$? If I use ...
9
votes
5answers
4k views

Interview solutions to reverse a string and reverse a sentence

Recently in an interview I was asked to Write a method to reverse a string. I used StringBuilder but was asked not to use reverse method of builder but iterate ...
9
votes
2answers
274 views

Area calculator for shapes as an OOP interview test

A while ago a tricky C++ interview question came across to me, and ever since I could not tell what I did wrong. Create a base class named “Shape” with a method to return the area of the shape. ...
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 ...
9
votes
4answers
4k views

Summing the first 1 to n powers of 2

At a JavaScript test for a job, I was asked the question below. I believe there has to be a better way to accomplish the same result, but I couldn't find any. If some JavaScript geek would take a look ...
9
votes
6answers
4k views

FizzBuzz Implementation in Java

Fairly new to learning interview questions and I saw this one and gave it a shot. I would very much appreciate some constructive criticism of how I went about it and what you would tell me if you were ...
9
votes
2answers
26k views

Simple application for finding local restaurants

I was asked to create a test APK file by a company HR when I applied for an Android developers job, Specification: The goal is to develop a simple application which finds the local restaurants. ...
9
votes
3answers
40k views

Converting int value to String without using toString and parseInt method

I am studying about the converting int to string and string to int without using toString and parseInt method. I already made ...
9
votes
5answers
457 views

Reverse a domain name string

For an interview question, I was asked to do the following: Given a dot separated domain name, reverse the domain elements. Here are a few input/output examples: ...
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
4answers
7k views

Review of object oriented design for a sample interview question

I'm going over the interview questions from "Cracking the Coding Interview" and one of the chapters (Chapter 7) deals with Object Oriented Design (OOD). The requirements for one of the problems are as ...
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 ...
9
votes
1answer
1k views

Implementing a string class in C++

I recently attended an interview for a C++ position in a very reputed bank. The interviewer started off by asking me to implement a string class but was only interested in constructor, copy-...
9
votes
1answer
3k views

Finding the length of shortest transformation sequence from start to end

Please treat this as a interview at a top tech firm, and share your thoughts on how you think I did. Be honest, and leave no stone unturned. Problem: Given two words (start and end), and 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 ...
9
votes
3answers
3k views

Extracting elements from multiple sorted lists efficiently

I was asked this interview question recently. I was able to come up with this which runs in \$O(k \log n)\$. Given k <= n sorted arrays each of size n, there exists a data structure requiring \$...
9
votes
1answer
263 views

Job listings database project in Node.JS

Build a project which can allow user to post and search for job listings, I have written some code and divided into different modules. My motivation is to understand how much over-engineering is ...
8
votes
4answers
466 views

Implementing common fraction using TDD

Recently, during the interview, I was asked to implement basic arithmetic operations with common fractions using TDD. The task is fairly simple, but I was nervous so I did not do too well. :) Later on ...
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. ...
8
votes
2answers
3k views

Implementing division without addition, multiplication, division or subtraction - follow-up

This is a follow-up to this question: Division without using addition, multiplication or division Could you please tell me if there is better way of performing division without ...
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 ...
8
votes
5answers
765 views

Calculating the area of a circle

This is one of tasks, which I had to do for the recruitment process at some company. Unfortunately they didn't like it so I've decided to share it here for discussion. CircleArea.h ...
8
votes
5answers
7k views

Write a method to replace all spaces in a string with %20

I have implemented a solution to this Cracking the Coding Interview question: Write a method to replace all spaces in a string with %20. You may assume that the string has sufficient space at the ...
8
votes
6answers
804 views

Implement queue using two stacks

Although it's a well-known algorithm, I thought to implement it from the perspective of a coding interview. I want to know if I can improve my code somehow. So, given the time constraint, is this a ...
8
votes
4answers
10k views

Calculate final test score from a list of test results

Recently I have given an interview to a widely well-known technology firm. The first interview was general and it went well but they rejected based on some technical things. They did not mention it so ...
8
votes
2answers
12k views

Generating a list of alternatively positioned odd and even number out of an array of unsorted integers

I had an half an hour interview with Microsoft for an intern position. I was asked to generate a list of alternatively positioned odd and even number out of an array of unsorted integers. I guess it ...
8
votes
3answers
7k views

Reversing every word in a string

Examples: char test1[] = " "; char test2[] = " hello z"; char test3[] = "hello world "; char test4[] = "x y z "; Results: ...
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: ...
8
votes
2answers
5k views

Determine if string has all unique characters

I'm working my way through the exercises of the book Cracking the Coding Interview. I'd like to review my solution for the question: Implement an algorithm to determine of a string has all unique ...
8
votes
3answers
655 views

Computing the relative magnitude of the values in one double array to another

An interview question I received: You are given two unsorted lists of positive doubles x contains the results from experiment 1 ...
8
votes
2answers
1k views

Breaking of a sentence

(Method signature is given with parameters) Try to visualize me writing this code at an interview, and please be brutal while judging it. Problem: Given a string s and a dictionary of words ...
8
votes
2answers
252 views

Function invocation every second time

Recently I got test task at the project, it is fairly simple: ...
8
votes
2answers
565 views

Sorting and searching problem related to a group of people standing in a rectangle

Please be brutal, and let me know how I've done on this problem, provided I coded it at an interview for a top tech firm. Time it took me: 44 minutes Worst case time complexity: O(n2)? Am I right? ...
8
votes
3answers
348 views

Use up all characters to form words

Task: Given a dictionary of words, and a set of characters, judge if all the characters can form the words from the dictionary, without any characters left. For example, given the dictionary {...
8
votes
2answers
682 views

Analyzing records of London Underground outages

You have a file that describes historic data of the London Underground showing dates when stations have been unavailable. The file contains these fields, separated by a pipe character: Date: ...
8
votes
4answers
3k views

Given two sorted arrays, add the elements of the second array into the first

In Cracking the Coding Interview by Gayle Laakmann McDowell, there's a question that asks you to write code for the following: Given two sorted arrays, A and B. Write a method merging the elements ...