Coding Interview Questions
- 0of 0 votes
Answersin Cracking the coding interview book 6th edition page 42 says that O(5 * 2^n + 1000 * N^100) = O(2^n)... I tried a sample code and got n^100 is greater than 2^n...
- Surender.sharma08 October 12, 2020 in United States| Report Duplicate | Flag | PURGE
Alcatel Lucent Applications Developer Coding - 0of 0 votes
AnswersQuestion 2) You have given a 2D binary matrix of size M[N-1][N-1]. Consider 1's as a
- A V September 23, 2020 in India for Ring
path and 0's as a deadend. The person starts from M[0][0] and needs to reach at point
M[N-1][N-1]. He can either move forward and down. You need to calculate the path to
reach the destination.
M[N][N] = 1 0 0 0
1 1 0 0
0 1 1 0
1 1 1 1| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 1of 1 vote
AnswersProgram to find the frequency of each element in the array OR write a program to count the occurrence of each number in a given string
- anonymous August 25, 2020 in United States| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 1of 1 vote
Answersfind the maximum length subarray condition 2 * min > max
- samayragoyal990 March 16, 2020 in India| Report Duplicate | Flag | PURGE
Adobe Backend Developer Arrays Coding - 1of 1 vote
AnswersWhat to do when we are poor on coding
- shekharlevadi100 December 21, 2019 in India| Report Duplicate | Flag | PURGE
Accenture Software Engineer Coding - 0of 0 votes
AnswersImplement a rate limiter that multiple threads can use, while the global rate is limited to a value
- neer.1304 July 22, 2019 in United States| Report Duplicate | Flag | PURGE
Rubrik Coding - 1of 1 vote
Answers"Good Range"
- Mit25 May 29, 2019 in United States
There is a number space given from 1 to N. And there are M queries followed by that. In each query, we were given a number between 1 to N (both inclusive). We add these number one by one into a set.
Good range: A range in which there is exactly one element present from the set.
For each query, we need to find the good ranges. We need to return the sum of boundry of all good ranges.
Input:
First line will take two integer for input N and M.
Then following M lines would be numbers between 1 and N (both inclusive).
Output:
Following M lines contains sum of boudaries of good ranges.
Note:
Range can consist of single element and represented as (x-x) where boundary sum will be x+x.
Example:
Input:
10 4
2
5
7
9
Output:
11
18
30
46
Explaination:
step-1) set: 2
good range: (1-10)
sum: 1+10=11
step-2) set: 2 5
good range: (1-4), (3-10)
sum: 1+4+3+10=18
step-3) set: 2 5 7
good range: (1-4), (3-6), (6-10)
sum: 1+4+3+6+6+10=30
step-4) set: 2 5 7 9
good range: (1-4), (3-6), (6-8), (8-10)
sum: 1+4+3+6+6+8+8+10=46| Report Duplicate | Flag | PURGE
Amazon SDE1 Coding - 0of 0 votes
AnswersDesign Movie Review system using OOP concepts. Code should pass all test cases.
- shushantsharan May 20, 2019 in India| Report Duplicate | Flag | PURGE
Flipkart SDE1 Coding - 0of 0 votes
AnswersGiven two strings, A and B, of equal length, find whether it is possible to cut both strings at a common point such that the first part of A and the second part of B form a palindrome.
- nemishsangani96 March 23, 2019 in India
Extension1. How would you change your solution if the strings could be cut at any point (not just a common point)?
Extension2. Multiple cuts in the strings (substrings to form a palindrome)? Form a palindrome using a substring from both strings. What is its time complexity?| Report Duplicate | Flag | PURGE
Algorithm Coding Computer Science Data Structures Dynamic Programming String Manipulation - 0of 0 votes
AnswersWrite a retry function, continue to fetch data until u have exhausted max entries. If it fails, continue to retry until retry's have been exhausted.
- pri9 February 16, 2019 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Coding - 1of 1 vote
AnswersGiven a directed graph and a node , find the shortest cycle in a graph with given node .
- saurabh January 23, 2019 in India| Report Duplicate | Flag | PURGE
Google Software Developer Coding - 3of 3 votes
AnswersHow to find out distinct ngrams from a email_alias.
- ashwini.padhy89 December 05, 2018 in India
For instance xyz@gmail.com here the email_alias is xyz.for xyz if we want to find bigram then function should have input the email_id,and the number of grams lets say 2.
Than it has to return the distinct count of ngrams present in the email_alias.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Coding - 0of 0 votes
AnswersIt was a online coding round on software provided by samsung itself.
- @nnonymous October 07, 2018 in India
Given a graph print either of the set of the vertices that are colored with the same color. And if the graph is not bipartite print “-1”. Test cases also included the cases when a graph is not connected.
Note: No STL or other library functions were allowed| Report Duplicate | Flag | PURGE
Samsung Software Engineer Coding - 0of 0 votes
Answersyou are given two arrays .You have to print minimum number of swap operation to perform so that the median of two arrays are equal. if not possible then print -1.
- 1x23xyz September 20, 2018 in India
link = https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/equal-median-8aba723b/| Report Duplicate | Flag | PURGE
Coding - 9of 9 votes
Answersprint hockey stick number in pascal triangle where row of triangle can be upto 30000 and length of stick can be upto 100.
- Randhir September 09, 2018 in India| Report Duplicate | Flag | PURGE
Wissen Technology Software Developer Coding Data Structures Dynamic Programming Java - 0of 0 votes
AnswersYou are given a set of functions:
int open_port(); opens a serial port and returns 0 if everything ok (or -1 if error) int read_port(char *buf, int buf_size) which reads data from a serial port and stores it to 'buf' of size 'buf_size' or blocks until the data is available and returns the number of bytes read (or -1 if error occurred) void close_port(); closes a serial port connection
Design a class:
class SerialConnection { public: using ByteHook = std::function<void(char)>; SerialConnection(ByteHook callback); .... };
which should read data from the serial port asynchronously and send it to the callback function ByteHook byte by byte (e.g., for decoding).
- pavel.em August 24, 2018 in United States
Note that if you don't call 'read_port' often enough, the underlying system buffer might get full and some bytes will get lost..
Which data structures / sync primitives you are going to use ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Coding - 0of 0 votes
AnswersA car has to be given on rent. Different people come and ask for it for interval [s,e] and offer some price p. To whom shall the car be given in order to earn maximum.
- Ankita August 22, 2018 in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Coding - -1of 1 vote
Answerwrite a main program to take snapshots of VMs
- samayragoyal990 August 10, 2018 in United States
Input: List of VMs(vmId: String), list of SLAs -> there is one-to-one mapping from VM to SLA
class SLA {
int freq_in_mins;
}
vm1 -> sla1{30 mins}
vm2 -> sla2{60 mins}
Constraints:
1) You can use takeSnapshot(vmId: String) -> Synchronous - I/O
2) If you start a snapshot of VM(with sla1) at time t0 and if it finishes at time t1, then the next snapshot should be scheduled at t1+sla1.freq_in_mins
vm1 at 00:00 and vm2 at 00:00
00:10 and 00:15
vm1 -> 00:10 + 30 = 00:40| Report Duplicate | Flag | PURGE
Google SDE-3 Coding - 0of 0 votes
Answerswrite a class that 1) calculates the average of the stream, 2) provides an API read the average.
- samayragoyal990 August 10, 2018 in United States
Handle overflows as the numbers can be very large and not fit into double/long.| Report Duplicate | Flag | PURGE
Facebook SDE-3 Coding - 0of 0 votes
Answers
- don99492 July 16, 2018 in United StatesGiven a string “SELECT c1,… FROM (SELECT c2,… FROM (…) WHERE c2=v2,…) WHERE c1=v1,…”, format to the following by inserting "\n" and "\t": “SELECT c1,… FROM ( SELECT c2,… FROM ( … ) WHERE c2=v2,… ) WHERE c1=v1,…
| Report Duplicate | Flag | PURGE
Coding - 0of 0 votes
AnswersMulti -level cache system design with different storage in each level.
- ANONU June 22, 2018 in United States
Read Operation : – Minimum time to read a particular key from cache system. This should be followed by writing the key in all levels above it. Eg. if “key” is found at level ‘i’, add this key to cache present at 1 to i-1 level.
b. Write Operation: – Any write Operation should write in cache of all levels.
You can choose any algorithm for cache management like LRU, MRU.| Report Duplicate | Flag | PURGE
Google Java Developer Coding - 0of 0 votes
AnswersBecause Ethereum smart contracts are deployed publicly, anyone with the right tooling can read their contents.
- drew.sen.8288 June 17, 2018 in Canada
Furthermore, people can access any state the contract specifies. Knowing that people have access to your
validation code, how do you write the contract so that somebody *must solve the problem. (*it should be near
impossible or significantly computationally expensive to derive the answer from your contract code)| Report Duplicate | Flag | PURGE
DMG Blockchain Blockchain Developer Coding - 0of 0 votes
AnswersEthereum is a blockchain that can run arbitrary programs. Write an ethereum program (i.e. contract) that will send 0.1 ETH (a bounty) to the first person who gets the correct answer to the above "100-digit"
- drew.sen.8288 June 17, 2018 in Canada
question.| Report Duplicate | Flag | PURGE
DMG Blockchain Blockchain Developer Coding - 0of 0 votes
AnswersGiven a wall, which is made up of two types of bricks (Porus / opaque ). Porus bricks allow water pass through them. Opaque won't. Find whether water reaches to ground, if there is any rainfall.
- gopi.komanduri June 11, 2018 in India for Office
Water can flow from top to bottom, diagonally, horizontally as well. Only flowing from bottom to top is not possible.| Report Duplicate | Flag | PURGE
Microsoft SDE-3 Algorithm Arrays Brain Storming Coding Data Structures Dynamic Programming Problem Solving Programming Skills - 1of 1 vote
AnswersGiven a string as input, return the list of all the patterns possible:
'1' : ['A', 'B', 'C'], '2' : ['D', 'E'], '12' : ['X'] '3' : ['P', 'Q']
Example if input is '123', then output should be [ADP, ADQ, AEP, AEQ, BDP, BDQ, BEP, BEQ, CDP, CDQ, CEP, CEQ, XP, XQ]
- ngupta32@hawk.iit.edu March 30, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm Coding Data Structures - 0of 0 votes
AnswerGiven a singly linked list, Your task is to remove every Kth node. The task is to complete a method deleteK that takes two argument, head of linked list and an integer k.The method returns the head of the new linked list. There are multiple test cases. For each test case, this method will be called individually.
- referthisfirst February 27, 2018 in India for Front End| Report Duplicate | Flag | PURGE
referthisfirst.com Site Manager Coding - 0of 2 votes
AnswersI am surprised by this GS question.I thought this is one of the classic number theory partition problem which is so hard that the best algorithm is approximation one.
- hprem991 February 22, 2018 in United States
Given value, find all possible combination of ways which equals to that sum.| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer Coding - 1of 1 vote
AnswersGoogle Fucked up question.
- hprem991 February 21, 2018 in United States
Given a random list of appointments (Start Date , End Date). Find all the appointments that are colliding.
This pretty easy looking question screwed me up today.There are tons of edge cases, I couldn't complete em all and 45 minutes pass like 15 minutes while explaining and coding same time.| Report Duplicate | Flag | PURGE
Google Software Engineer Coding - 1of 1 vote
AnswersImagine a computer where you have no "/" (divide) operation. All other operations are implemented including addition, multiplication, binary shift etc. Implement function div(int a, int b) using available operators only.
- godzilla February 14, 2018 in United States for unknown| Report Duplicate | Flag | PURGE
Riot Gaming Software Engineer Coding