Questions tagged [interview-questions]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
124 views

Check for max value in stack

Got this problem in a coding interview - Get the max value of a stack in O(1). The stack contains numbers only. Please review my solution. ...
2
votes
2answers
47 views

Find the 'n' most frequent words in a text, aka word frequency

I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name. The ...
2
votes
2answers
136 views

Fake Interview Scenario: Hangman

For a fake interview I decided to write Hangman. The first question I have is when reviewing someone's code for a job interview is it more important to write something short and sweet that gets the ...
0
votes
1answer
32 views

Hackerrank Gridland Metro - using Interval Cover Solution

Hi there I was hoping to get a better grasp of greddy algorithms while trying to solve this problem: Hackerrank: Gridland Metro and I was trying to apply an algorithm where each grid could be ...
4
votes
3answers
565 views

Compute shortest path in undirected graph

In a recent coding interview I was asked to write a program which takes as input two text lines: The first one represents a graph, formatted as a sequence of undirected edges like ...
0
votes
2answers
184 views

Interview: Drug Analyzer class

the introduction is this: You are a member of a biotechnology programming team that is responsible for creating a system for lab technicians, which will assist them with drug analysis. Your goal is ...
5
votes
1answer
507 views

Designing an URL Shortener

Recently I was assigned a URL shortener design problem while interviewing with a well known organization. Here is the exact problem statement: Build a simple URL shortener service that will accept a ...
1
vote
1answer
82 views

Square Spiral Matrix in Javascript

I've been grinding some Leetcode for an interview coming up and just completed Square Spiral in Javascript. Looking for feedback on performance. This ranked faster than 58% of submissions, would there ...
1
vote
1answer
108 views

Is My Controller too Coupling?

To put it in context, I had the assignment to do for a job interview in Node.JS, which basically making CRUD with products (and it have certain conditions). The assignment was well-understandable, and ...
6
votes
1answer
1k views

friend locator app

I was rejected after a tech screening for the following code. I mainly struggled to make the code 'production ready'. I was running out of time so I did not create a class for testing. How could I ...
2
votes
2answers
90 views

Print Binary coded decimal Numbering of a given input number

Example 1 input:3 output:0011 Example 2 input : 15 output: 1111 in the below example code 15 is input. I have taken 8 4 2 1 as array for Binary coded decimal numbering this code is working as ...
3
votes
3answers
1k views

Printing rotations of an array 7 times

Loop through a given array 7 times and print the following output: int[] arr = { 9, 2, 7, 4, 6, 1, 3 }; ...
0
votes
0answers
27 views

REST API in react native

In a recruitment process, the company gives me a project to do in react native. I finished all the tasks. But company gave me a feedback and said that your project was good, but you did not apply best ...
3
votes
2answers
422 views

Function that receives a string fraction and has to return said fraction reduced

I got this exercise on a job interview and i'd like to know how can i improve my code. Exercise: Create a function that returns a reduced version of a fraction. Examples Reduce("4/6") = &...
1
vote
0answers
75 views

Find the number of carry operations needed to add two numbers digit by digit

I don't know if my test cases at the bottom cover every case, or if my mathematical logic in the reducer function is exactly right (referring to the math that starts with ...
2
votes
2answers
58 views

LeetCode Reverse Nodes in k-Group

Link: https://leetcode.com/problems/reverse-nodes-in-k-group/ Problem description: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive ...
3
votes
1answer
48 views

Simple command line API client for getting quotes

Was given a take-home test as part of a job interview, which I failed due to a supposed lack of tests, logging, error handling and packaging. But I did touch upon all of these.. suggested time spent ...
1
vote
1answer
131 views

C# Coffee Machine

I saw this post and tried to do my attempt. This is the requirement of task: Design a coffee machine which makes different beverages based on set ingredients. The initialization of the recipes for ...
3
votes
1answer
154 views

Python script to parse XML file into Json

How are you doing? I have to make a script to parse an xml input file to a json file. I tried to do my best, but it will be nice if you could check it and help me to improve it. The idea is that I don'...
0
votes
2answers
389 views

InterviewBit Problem: Stringoholics

I am trying to solve https://www.interviewbit.com/problems/stringoholics/ InterviewBit problem. Problem Statement: You are given an array A consisting of strings made up of the letters ‘a’ and ‘b’ ...
4
votes
1answer
150 views

Randomly rearrange table rows without unnecessary reflows

I recently completed a coding challenge for a company that did not get me to the next stage. They were kind enough to provide the following feedback: The coding assignment does not match what we are ...
9
votes
5answers
2k views

Unit test for a maximum-finding function

A while ago, I got this question as a part of an interview test which asked to write a function to find the biggest number in a vector and write all the unit tests required to show that the code works ...
2
votes
0answers
34 views

Find all of the paths that lead to the minimum sum [closed]

"Find minimum path sum" in a 2D grid, is a very popular question which is solved by dynamic programming. But what if instead of the minimum sum value, we return all the actual paths that ...
2
votes
0answers
53 views

Cron expression parser

Problem Write a command line application or script which parses a cron string and expands each field to show the times at which it will run. ~$ your-program "*/15 0 1,15 * 1-5 /usr/bin/find"...
0
votes
1answer
282 views

Implement an algorithm for a room cleaning robot

I wanted to ask this question to my interview candidates, hence wanted to first give it a shot to see if this is doable in 45 mins. Here's the code that I was able to come up with in 45 minutes. Can ...
1
vote
5answers
150 views

FizzBuzz solution

I'm preparing for junior developer interviews and am trying to come up with a more interesting/versatile solution to FizzBuzz than I've done in the past. Do you have any ideas of how I might DRY this ...
2
votes
0answers
35 views

Rainfall challenge: procedural implementation

This evening I have seen the text of the Rainfall Challenge posted seven years ago by Hunter McMillen. I did not look at his solution (besides, I have no clue about perl), but I was intrigued by the ...
2
votes
1answer
233 views

Implementation of a ticket queue system in JavaScript

I got this question during an interview. The question itself was very open-ended - it asked me to implement a ticket queue system, where by default it would have 3 different queues to hold tickets ...
2
votes
2answers
75 views

Count edit distance

I have implemented a C code in order to answer an interview question. I would be appreciated if someone would improve the code. Task is an easy, however I want to achieve best efficiency in terms of ...
2
votes
2answers
62 views

remove kth last element from singly-linked list - Follow up

This code is a revised version of implementation which asked for an improvement. Original question is asked here: remove kth last element from singly-linked list credits to: Toby, Andreas, Arkadiusz ...
0
votes
2answers
127 views

remove kth last element from singly-linked list

I have implemented a code to solve following problem. I would like to improve the code efficiency. Pardon if I just printed out the result. Code has O(N) time and constant space complexity. Given a ...
2
votes
1answer
110 views

Find minimal modulo-sum of pairs from two lists

Recently I appeared for an job challenge organised on HackerEarth. Question: There are two teams T1 and T2. Power of each player is represented in array. The rules of game are as follow. There are ...
3
votes
1answer
162 views

strstr implementation with python and sets

Please review my strstr implementation in terms of time/space efficiency and overall readability. I am preparing for a coding assessment coming up as I am looking to pivot my career from Physics to ...
1
vote
0answers
52 views

Find room required for lectures

I have implemented a code to resolve following interview question. Please advice how it can be improved folks. Thanks in advance. Given an array of time intervals (start, end) for classroom lectures (...
2
votes
0answers
74 views

Find the largest contiguous sum of two or more integers in an array of positive or negative integers?

I received an interview question: Find the largest contiguous sum of two or more integers in an array of positive or negative integers. I wrote a brute force solution, which is slow at O(n^2). Is ...
1
vote
1answer
25 views

Record transaction log

I am trying to resolve following problem to improve my DS knowledge. Please advice which part of the code can be improved. You run an e-commerce website and want to record the last N order ids in a ...
2
votes
3answers
270 views

Chess knight move simulator

I was asked to write chess simulation of pieces as a take home interview question and was given this spec. This is what I came up with: ChessGenerator.java ...
3
votes
1answer
34 views

Counting unival subtrees - Follow Up

This code is a revised version of the implementation which asked for an advice on improvement. Original post here: Counting unival subtrees Credits to: [Deduplicator], [Reinderien], [Toby Speight], [...
3
votes
2answers
215 views

Build a stamp duty calculator for various types of buyers

I had a task where I had to build a stamp duty calculator, which calculates the tax or stamp duty first-time buyers(ftb) returning buyers (...
2
votes
0answers
84 views

Create array given number of larger elements to right of each member

I want to improve on my original solution to this problem, my solution is O(n^2) and I think it's possible to solve in less time You have two arrays: A and B. A contains ints and B has pairs: (...
6
votes
4answers
133 views

Counting unival subtrees

I have written some code to solve the following interview question. Please advise how it can be improved. Thanks in advance. A unival tree (which stands for "universal value") is a tree ...
2
votes
3answers
62 views

Encode message by alphabets - Follow Up

This code is a revised version of implementation which asked for a advice. Original question is here: Encode message by alphabets ...
5
votes
1answer
55 views

Multithreaded number printer in ordered manner

On recent interview I was asked to write program that print "Zero" and "One" to stdout from different threads, but in ordered manner: ...
5
votes
4answers
289 views

Product of all but one number in a sequence - Follow Up

This question is a follow up question to the Product of all but one number in a sequence. I am posting a new code here with taking into consideration the suggestions of [Edward], [CiaPan], [chux], [...
7
votes
2answers
819 views

XOR linked list implementation

I am trying to resolve below question in order to prepare for an interview xD An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields, it ...
6
votes
1answer
108 views

LeetCode: is subsequence C#

https://leetcode.com/problems/is-subsequence/ Given a string s and a string t, check if s is subsequence of t. A subsequence of a string is a new string which is formed from the original string by ...
12
votes
4answers
762 views

Product of all but one number in a sequence

I was given the following prompt in a coding interview: Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the ...
4
votes
3answers
368 views

Microsoft OA | Longest Substring Without 3 Contiguous Occurrences of Letter

For the following question, does my JS Solution seem correct? I'm looking for some peer review. Q: Given a string s containing only a and b, find longest substring of s such that s does not contain ...
7
votes
2answers
319 views

Take postcodes and get the Lat long information from them

I had an interview task which was the final stage, however, the feedback I got back for my solution was that it lacked effort and structure. I would be grateful to ...
4
votes
2answers
117 views

LeetCode: Insert delete getrandom o1 C#

https://leetcode.com/problems/insert-delete-getrandom-o1/ please comment on performance Implement the RandomizedSet class: bool insert(int val) Inserts an item val into the set if not present. ...

1
2 3 4 5
19