Questions tagged [interview-questions]

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

Filter by
Sorted by
Tagged with
7
votes
2answers
3k views

Finding alternating sequence in a list of numbers

Please be brutal and treat this as me coding this up for an interview. A sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between ...
7
votes
2answers
3k views

Pascal's triangle for an interview in PHP

I saw that one of the interview questions could be building a pascal triangle. Is there anything wrong with this particular solution I came up with? ...
7
votes
1answer
2k views

Counting the overlapping intervals in the union of two sets

I had to recently implement a code to count the union of all intervals (if there are overlapping intervals) for an interview. I was provided with the following function stub: ...
7
votes
1answer
567 views

Shortest path to transform one word into another

I submitted the following code for a job application, and was rejected. They gave no feedback. Would appreciate any comments on the approach I took, and coding style. This is the question: Given ...
7
votes
1answer
239 views

Make Simultaneous HTTP Requests That Resolve Into a Single Return

This week, in an ongoing job search, I was tasked with the following pre-screening question: Make two simultaneous http requests. Use the language and library of your choice. Make sure the results ...
7
votes
4answers
289 views

Add one to a very large integer

I was asked to implement this in an interview a while back. I didn't pass the interview, mostly likely because it took me far too long to do. However, I'm interested to know how well implemented the ...
7
votes
1answer
625 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 ...
7
votes
1answer
813 views

Designing yet another coffee machine, Lombok style

After reading Designing a coffee machine, I decided to implement the same problem as an exercise to get to know Guava and Lombok. I used the problem statement from the given question: Design ...
7
votes
1answer
76 views

Find neighboring PINs on a numeric keypad

I am new to coding and to apply for an internship I need to solve several tasks. This is one of them. I wrote working code, but the program says it takes too long to complete. Help me speed up my code ...
7
votes
1answer
3k views

Merge k sorted link lists in python

I got asked this following interview for the following problem. Wondering if you have any thought and feedback for 3 solutions below: Merge k sorted linked lists and return it as one sorted list. ...
7
votes
2answers
439 views

Codility: An activity selection problem about scheduling two enemies to watch movies at a festival

I don't remember the exact wording of the question, but it is clearly an activity selection problem, which is [...] notable in that using a greedy algorithm to find a solution will always result in ...
7
votes
2answers
2k views

Android App Interview (Minesweeper game)

I recently did an Android Minesweeper app for a pre-interview coding challenge before I could talk to any engineer and was rejected. This feedback was given but I'm not sure on some of it. ☺︎ Game ...
7
votes
2answers
3k views

Searching in a sorted 2D matrix

If I was at an interview, and wrote this code, what would you think? Please be brutal. Time it took to wrote it: 13 minutes Problem: Write an efficient algorithm that searches for a value in an m ...
7
votes
1answer
1k views

Flatten double-linked list

Consider this interview question: Given a Node with a reference to a child, its next, its previous, and a variable for its value (\$\frac{1}{2}\$ tree, \$\frac{1}{2}\$ doubly linked list ...
6
votes
7answers
3k views

Check if a string has all unique characters

This is a question from the book "Cracking the Coding Interview". Implement an algorithm to determine if a string has all unique characters What if you can not use additional data structures? I ...
6
votes
5answers
6k views

Given a String, return a boolean if it is a number

Yesterday in an online interview, the interviewer asked me this question: If I give you a string, you have to return if a string is number or not. You are not allowed to use any parse function ...
6
votes
5answers
2k views

A custom String Builder implementation

Two code files below : the actual logic & the test logic. Core Logic ...
6
votes
5answers
4k views

Writing FizzBuzz

First of all, I came up with that question on SO already. But I am offered different solution which are "better" in some ways. The goal is to improve this specific version, not to create another one....
6
votes
7answers
10k views

Printing a multiplication table

I was recently given a coding test by an employer. After the test, this was the employer's response: "I’d say that a lot of his solutions were pretty inefficient and took a very ‘brute force’ ...
6
votes
4answers
8k views

Checking balanced parenthesis string

I recently wrote a code in online recruitment test. It was very good. With each question, there were associated space and time limits check. If our code executed correctly within both limits, only ...
6
votes
4answers
2k views

Finding the duplicate with an array with 1,000,000 integers between 1 and 1,000,000

I recently had an interview and got to phase 2 which is a coding assessment. One of the questions was: Given an array with 1,000,000 integers between 1 and 1,000,000, one integer is in the array ...
6
votes
3answers
19k views

Client Sends XML, Server Parses XML, Queues Up and Executes Commands

I recently had a Java interview where I was asked to write a client-server application. I don't code primarily in Java, but with my preliminary Java knowledge, I thought I built a reasonable working ...
6
votes
3answers
2k views

OOP Chess design job interview practice

please comment on game flow, Solid principle and OOP concepts. ...
6
votes
3answers
5k views

Football game using factory and command patterns

I'm really confused about the interview I did with a firm. They told my code was not expert, but almost intermediate level java. Requirements Football Scoring Dashboard Develop an application that ...
6
votes
2answers
199 views

Find char which appears maximal number of times

I had 15 minutes to code the following question: Given a file name return the char which appears maximal number of times. please do not take into account the unit test. Please look at the final ...
6
votes
3answers
765 views

Flatten an array

I have got this interview question which has asked me to write a production level code which flattens the arbitrary nested array of arrays. Code ...
6
votes
4answers
1k views

Detecting if two strings are anagrams using TreeMap

I decided to use Java TreeMap because it seems like a great data structure to fit this problem. However, I am not sure if there could be much simpler methods using ...
6
votes
5answers
767 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 ...
6
votes
3answers
1k views

Print pair representing objects from sequence of nonnegative integer pairs

There are some things I am not sure of from a professional standpoint about the "correct" way to write C++ code. I have been looking through source code produced by various opensource projects, as ...
6
votes
4answers
206 views

Building a toy from Lego toys

I recently attempted a coding problem, but my solution was not well received during the interview (modified slightly to reduce Google-ability). Suppose a child has several Lego blocks, and wants to ...
6
votes
4answers
1k views

Sufficient implementation of subset sum for 45 min interview

I am preparing for interviews, and have implemented a solution to this problem from Geeks for Geeks: Given a set of non-negative integers, and a value sum, determine if there is a subset of the ...
6
votes
2answers
2k views

PayCheck calculator software

I was participating in a job selection process and one of the tasks I was asked to do was to develop a take home pay application to let users to calculate their paychecks based on their location. ...
6
votes
3answers
8k views

Shopping Cart design interview task

I was interviewed for one position and had the following task. The goal is to design system according step 1, then adapt it to additional requirements in step 2. Step 1: Shopping cart You are ...
6
votes
3answers
2k views

Print all anagrams together in a sentence in Java

I know a lot of memory is being used, but how do I make this more efficient in space(and time) . ...
6
votes
2answers
24k views

Binary Search Tree implementation using templates

I wrote this implementation using templates. It works fine and as expected. Just want to know if this can be improved. I have some specific questions too at the end. Please feel free to critique to ...
6
votes
4answers
379 views

Interview practice: Integer to Roman

Student here. I'm practicing for coding interviews right now. In that context, how would you recommend I improve my code for this practice problem? ...
6
votes
2answers
5k views

Tree traversal into List

The interview question was to traverse a tree into a list. ...
6
votes
2answers
3k views

Find maximum gap between elements of an array

I am solving interview questions from here. Problem : Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j]. Example : A = [3 5 4 2] Output :...
6
votes
2answers
4k views

Ways to improve my coding test FizzBuzz solution for a TDD role?

I had an interview recently where I was asked to produce the traditional FizzBuzz solution: Output a list of numbers from 1 to 100. For all multiples of 3 and 5, the number is replaced with ...
6
votes
2answers
127 views

Find top two clothing sizes in the array

I was recently asked this question in an interview. Here is the solution I came up with. Please let know if I could have done this differently or in a more efficient manner. The question is as ...
6
votes
2answers
862 views

Counting ambiguous Morse Code encodings, with and without Java Streams

Unique Morse Code Words International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ...
6
votes
5answers
5k views

Simple online auction system in Java

I recently applied for a Java developer position and I was asked to completed a coding task. After review of the coding task, the company said they do not want to take me forward to interview. They ...
6
votes
3answers
270 views

HTTP site scraper

A job application of mine has been declined because the test project I submitted was not coded in a clean and straightforward way. Fine, but that's all the feedback I got. Since I like to ...
6
votes
3answers
211 views

Function to return subword of a camelcase string

Given a camelcase string and an index, return the subword of the string that includes that index, e.g.: ...
6
votes
5answers
5k views

Find the sum along root-to-leaf paths of a tree

Most of you already know me, please be brutal, and treat this code as if it was written at a top tech interview company. Question: Given a binary tree and a sum, find all root-to-leaf paths where ...
6
votes
3answers
518 views

Finding the postion of a substring in a string

I am given two strings and return the position if in the larger string the smaller string is found. If not I am returning -1 for position. Any suggestions for improving my code. ...
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 ...
6
votes
3answers
3k views

Finding clusters in a matrix

I got asked at an interview to write a program that, given a NxM matrix with zeros and ones, prints out the list of clusters of 1s. The clusters are defined as patches of 1s connected horizontally, ...
6
votes
2answers
631 views

Simple Factorial Interview Task

I did this code for an interview. Can you tell me how it looks? I didn't get the job, so I'm wondering what I could do better in my code. ...
6
votes
3answers
2k views

interview question, friends, movies and likes

I was recently asked to implement an interface for a job interview. the class has methods to add customers and movies, the customers can watch or like movies and add friends. there are methods to get ...