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.

831 questions
Filter by
Sorted by
Tagged with
125 views

### Call center escalation excercise, using Chain of Responsibility pattern

This is a coding interview I found online, to be solved within 30 minutes: Design an OOP concept for an application where employee can dispatch their incoming phone call according to their ...
354 views

### Merge sort Java implementation for an interview

I just learned Merge sort, and I really like this Merge sort implementation since it is very logical and very easy to follow. If I was asked in an interview to implement merge sort, will this ...
101 views

### ZigZag tree travesal

The question is taken for a coding interview I had, it is also in geeks for geeks, https://www.geeksforgeeks.org/zigzag-tree-traversal/ you are given a binary tree and you need to print it in a ...
62 views

### Nodejs Interview - API calls and exchange rate

I did an initial technical phone screening with this company which went ok, they then sent me a programming exercise to complete and send back to them. The goal of the exercise: -take input as a ...
111 views

### Three Numbers in Java

Given three positive numbers A, B, and C. Find the number of positive integers less than D that are divisible by either of A, B or C. Input format The 1st argument given is an Integer A. ...
146 views

### Subset Sums in Java

Given an array of integers, print sums of all subsets in it. Output should be printed in increasing order of sums. Input : arr[] = {2, 3} Output: 0 2 3 5 Input : ...
2k views

### Sort all even numbers in ascending order and then sort all odd numbers in Descending order Java

Given an array of integers (both odd and even), the task is to sort them in such a way that the first part of the array contains odd numbers sorted in descending order, rest portion contains even ...
122 views

### Scroll text across a fixed width

In an interview, I was asked to write code to produce this output: T TE TES TEST EST ST T The code I wrote was: ...
138 views

### Interview Take Home Challenge: Chat server

Recent take-home challenge I was assigned from a recruiter prior to technical interviews with the team. The team wanted it written in GOlang (I had no experience in the language) but told the ...
84 views

### News reading application version 2

following the answer I got from t3chb0t last time News-reading application using the Observer pattern and also following the example here https://msdn.microsoft.com/en-us/library/dd990377(v=vs.110)....
518 views

### Iterator for BFS binary tree traversal

I implemented an iterator pattern for C# using IEnumerator and IEnumerable. The goal of the implementation is to traverse a ...
2k views

### Minimum swaps algorithm terminated due to timeout

I have been trying to solve this question. Given an unordered array consisting of consecutive integers [1, 2, 3, …, n], find the minimum number of two-element swaps to sort the array. I was able ...
195 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 ...
228 views

I was given 15 minutes to write the code to reverse a singly-linked list. What do you think of the code style here? ...
896 views

### Remove the first value for a doubly linked list

You need to remove the first element which contains a given value from a doubly linked list. I created two solutions since I find the edge case of removing the first element to be problematic. So I ...
2k views

### Sort an array of 0s, 1s and 2s in Java

Write a program to sort an array of 0's,1's and 2's in ascending order. Input: The first line contains an integer 'T' denoting the total number of test cases. In each test cases, First ...
1k views

### Are strings anagram

This is a question from the book "Cracking the Coding Interview". Write a method to decide if two strings are anagrams or not I think interviewer will not be convinced with this solution because ...
475 views

### Alone in a Couple implementation in Java

In a party everyone is in couple except one. People who are in couple have same numbers. Find out the person who is not in couple. Input: The first line contains an integer $T$ denoting ...
1k views

### Remove duplicate characters in a string

This is a question from the book "Cracking the Coding Interview". Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer NOTE: One ...
341 views

### In-place reverse of C-style string

This is a question from the book "Cracking the Coding Interview". Write code to reverse a C-Style String (C-String means that “abcd” is represented as five characters, including the null ...
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 ...
2k views

### Solving maze problem with backtracking solution using stack

I solved the maze backtracking question using a stack however could not find any other solution like that anywhere (to validate my solution is actually a valid one). The problem statement is as ...
412 views

### Group Anagrams Together approach in Java

Given an array of words, print the count of all anagrams together in sorted order (increasing order of counts). For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then grouped ...
69 views

### Top 2 Frequent Elements in JavaScript

I got the original problem from Leetcode for top k frequent elements, But I decide to simplify the problem just top 2 elements to make it simpler to solve. ...
310 views

I am preparing for multithreading interview questions and I don't have much experience with multithreading. I referred some online article to come up with a solution. Is this solution appropriate? <...
206 views

### Reversing the vowels in a String

Given a string, reverse only the vowels present in it and print the resulting string. Input: First line of the input file contains an integer T denoting the number of test ...
102 views

### Anagram checking implementation

Given two strings, check whether two given strings are anagram of each other or not. An anagram of a string is another string that contains same characters, only the order of characters can be ...
2k views

### 2D Maze solver using recursion in Python

A company I interviewed for sent me a coding problem to solve. The problem was to find a solution to a maze, not necessarily the shortest one. The input would be like so: ...
3k views

### Roman to Integer

I'm trying to get better as a programmer and would love any feedback on my code. Especially the section in the while loop. How could I make this more readable? What would your opinion as an ...
129 views

### Implementing an order system for a job interview

I have to implement a relatively basic order system in Java for part of the process of a job interview. At the moment I have working code that allows for the creation, and updating of orders for an ...
137 views

### Non repeating character in Java

Given a string s consisting of lowercase Latin Letters, find the first non repeating character in s. Input: The first line contains T denoting the number of testcases. Then follows ...
918 views

### Given a sorted array nums, remove the duplicates in-place

I wrote an algorithm to solve this challenge but would love some feedback on its efficiency and, if you were an interviewer, what your opinion would be on my solution. I believe my time complexity is \...
485 views

### Find all root to leaf paths in binary tree

Description: Given a binary tree, return all root-to-leaf paths. Leetcode ...
619 views

### Calculate implied volatility for options on stocks and futures with two models

I wrote a code for a quant finance job and they told me that, besides it worked, it was poorly written. I asked for a more detailed feedback but they did not send it to me. I paste it here with ...
602 views

### Find all k-sum paths in a binary tree

Description: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. Note: A leaf is a node with no children. Leetcode Code: ...
218 views

### Find minimum depth in a binary tree

Description: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node ...
122 views

### Star Elements implementation in Java

Given an unsorted array. The task is to find all the star and super star elements in the array. Star are those elements which are strictly greater than all the elements on its right side. Super ...
442 views

### Codility: MaxZeroProduct - complexity issues

My solution scored 100% correctness, but 0% Performance. I just can't figure out how to minimize complexity time. Problem: Write a function: ...
144 views

### Greater on the right side in Java

Given an array of integers, replace every element with the next greatest element (greatest element on the right side) in the array. Since there is no element next to the last element, replace it ...
86 views

### System on Chip Validator

With reference to my source files, published in the git repository soc-testing I did my best effort at coding, based on 30 years of experience, so I would like to know what I did wrong with my ...
147 views

### Function which would get the next n slots from the current time [closed]

I have attended an interview recently and my coding got rejected by the panel. I am new to Python and is mentioning my code below. Please help me improve the code quality or any bug: Question: Given ...
357 views

### Inventory allocation method

Recently I have attended an Interview with a firm. They gave me a task to complete. I have done it and tested it as well. But they rejected my code. Is the given code properly written? Is my coding ...
1k views

### Count the number of occurences of X's within a range in Java

Given an integer X within the range of 0 to 9, and given two positive integers as upper and lower bounds respectively, find the number of times X occurs as a digit in an integer within the ...
74 views

### Count total set bits

Im am solving Count total set bits: Find the sum of all bits from numbers 1 to N. Input: The first line of input contains an integer T denoting the number of test cases. The first line ...
595 views

### Check if array contains contiguous integers with duplicates allowed in Java

Given an array of n integers(duplicates allowed). Print “Yes” if it is a set of contiguous integers else print “No”. INPUT: The first line consists of an integer T i.e. the number of test ...
4k views

### Checking if two strings are anagrams in Python

The code written in Python 3.6 mostly using Python's built in functions sorted and len. First I'm checking for the edge case that the two given strings are not of ...
758 views

### Reverse a sentence in Java

You are given an array of characters arr that consists of sequences of characters separated by space characters. Each space-delimited sequence of characters defines a word. Implement a function ...
395 views

### Given an integer n, generate the nth count and say sequence

I am solving interview questions from here. Problem : Given an integer n, generate the nth count and say sequence. The count-and-say sequence is the sequence of integers beginning as follows: <...