Questions tagged [interview-questions]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
25 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 ...
1
vote
1answer
71 views
+50

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
69 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
54 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 ...
1
vote
2answers
78 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
92 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
61 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
35 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
70 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
18 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
121 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 ...
4
votes
1answer
28 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
208 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
110 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
55 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
48 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: ...
6
votes
4answers
285 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], [...
8
votes
2answers
740 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
75 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 ...
13
votes
4answers
717 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
215 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
264 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
80 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. ...
3
votes
0answers
44 views

LeetCode: Number of enclaves C#

https://leetcode.com/problems/number-of-enclaves/ Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land) A move consists of walking from one land square 4-directionally to ...
7
votes
4answers
1k views

How can I efficiently manipulate digits in a string without using RegEx in Java?

I am reading a book with different quizzes about coding interviews. Please implement a function that increments a string based on the rules below: It should take the string of unknown length and ...
5
votes
1answer
76 views

Graph: N Robots and M Nodes

I was recently told I need to change my coding style. An Interviewer told me he would like to see "more formalized class structure and organization". I have attached few of my cpp files. if ...
1
vote
2answers
133 views

What can I learn from this coding test?

So I was recently asked to complete the following challenge for an interview: Programming Problem Provide a production ready solution that accepts a new user name, validates a single string input as ...
5
votes
1answer
244 views

Sorting JSON items from a site

So I recently applied to this job for iOS Developer and was invited to complete the following code challenge: As a next step, please complete this coding exercise in order to proceed with our ...
3
votes
2answers
914 views

Find longest Palindromic substring

technical interview question i got from daily interview pro A palindrome is a sequence of characters that reads the same backwards and forwards. Given a string, s, find the longest palindromic ...
3
votes
2answers
79 views

Largest Sum Contiguous Subarray - Kadene's algorithm

I am looking forward to an answer to improve this code? Thanks. Test class ...
4
votes
2answers
169 views

Checking if a string contains all unique characters

I am currently reviewing CTCI(Cracking the Coding Interview) The question is asking me to implement an algorithm which checks whether the characters in a string are all unique however they do not want ...
4
votes
2answers
82 views

Replace nested property for an interview

During an interview I was given this interesting JavaScript task: Given the code: ...
5
votes
1answer
87 views

c# Efficient solution: Sequence generator for a pattern

This is an interview question to generate the below pattern of numbers in a sequence, which is: 12.34, 23.45, 45.67, 78.910, 1112.1314, 1617.1819, 2223.2425, 2930.3132, 3738.3940, 4647.4849, 5657.5859,...
2
votes
1answer
367 views

The intersection of two polygons in C++

I implemented the intersection of two (convex) polygons in C++. It finds the polygon in the intersection like in this image. Looking for any and all feedback. I left the logic for line intersection ...
5
votes
2answers
91 views

Sorting squares of an integer array

I had this question in an interview recently. Given a sorted array of integers, return a list of those integers squared, with the squares sorted. So given an array of these numbers: ...
1
vote
3answers
122 views

Refactor Java code

I was trying to solve the following question: You are given 2 arrays: one representing the time people arrive at a door and other representing the direction they want to go(in or out) You have to ...
1
vote
2answers
119 views

Cut Wood / Facebook Interview

This question was asked through the Facebook interview and the suggested solution is solving via binary search. I have put the binary search solution but it still looks too complicated. Question: ...
3
votes
2answers
140 views

Board Rotation Problem - Best Practices

Problem: You are given a board containing lower-case letters and a word that you have to form. You can only take the letters from the front or the back, hence you have to rotate the board left or ...
1
vote
1answer
60 views

Counting the number of click on the entire page

In an interview I was giving the following problem: Count the number of click on on the entire page. Can you think of a better way to do this? ...
1
vote
2answers
87 views

Merge two sorted arrays that can be of different sizes

I think the algorithm implementation itself is reasonably efficient, but I'm not sure about proper use of good practices in software development in the code (variable naming, idioms, comments, error ...
2
votes
1answer
67 views

Propagation in grid

Can I do it with a lower Big O / better code? How can I improve this solution? Task: Let's assume we have a array like this: 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 ...
3
votes
2answers
93 views

Finding average of stream of numbers

A Brief Context I recently gave an interview in a company where I was asked this particular question. After the interview was over, the HR gave the feedback that my solution (is correct ...
2
votes
1answer
67 views

Is there a route to the end of the jump table?

I'm currently learning about Dynamic Programming and solving a "coding question" related to the topic. Given an array of non-negative integers, you are initially positioned at the first ...
12
votes
3answers
2k views

Converting Roman numerals to integers

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. ...
1
vote
2answers
456 views

Calculate transaction balances and find duplicate transactions

In an interview I was asked to solve two JavaScript questions. I thought I did pretty well because I: Covered the edge cases Wrote comprehensive tests Documented the code using jsdoc The interviewer ...
4
votes
2answers
246 views

Query and display train and station information

Recently got this coding assignment as the first round of interview at a tech organization. I could get the expected result, however, my code failed the best practices check. Please let me know if it ...
1
vote
0answers
58 views

Wildcard Matching with DFS and FSM

I'm trying to solve Wildcard Matching on Leetcode. I found a great solution using the Finite-state machine. The author builds an FSM and searches with BFS. I rewrite the solution with the same idea (...
2
votes
0answers
79 views

ANDROID - Receive and manage markers in Google Maps

Recently, I've received negative feedback of interview's test. They say that they need somebody with higher technical level, the quality of the task was not good enough. I upload it here, to request ...
4
votes
0answers
84 views

Implement a micro service in Rust

Last year I tried to implement a micro service architecture in Rust. It was asked as a homework question in an employment interview process to be completed in a few days. The imagined use case was a ...

1
2 3 4 5
18