.Net/C Interview Questions
- 1of 1 vote
AnswersFind the two elements that have the smallest difference in a given array.
- si October 23, 2019 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer Intern Arrays - 0of 0 votes
AnswersWrite an iterator class to traverse the tree
- si October 23, 2019 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer Intern Trees and Graphs - 0of 0 votes
AnswersHow to traverse a tree?
- si October 23, 2019 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer Intern Trees and Graphs - -2of 2 votes
AnswersGiving a the following:
- xi.text.xi October 22, 2019 in United States for none
A list of a store items T={t_1, t_2,...,t_n}.
A list of prices of each item P={p_1, p_2,...,p_n}.
A list of quantities of each item Q={q_1, q_2,...,q_n}, respectively.
And total bill M.
Our goal is to find any possible list of items that its total value is equal to M using dynamic problem.
Write down a recursive solution.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 0of 0 votes
AnswersGiven an array of positive and negative integers {-1,6,9,-4,-10,-9,8,8,4} (repetition allowed) sort the array in a way such that the starting from a positive number, the elements should be arranged as one positive and one negative element maintaining insertion order. First element should be starting from positive integer and the resultant array should look like {6,-1,9,-4,8,-10,8,-9,4}
- sameerasusmitha October 21, 2019 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 1of 1 vote
AnswerDesign a service to scan photos/videos for any malware
- novastorm123 October 16, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon System Design - 0of 0 votes
AnswersDesign APIs around, storing into and retrieving from, an Amazon Warehouse locker.
- novastorm123 October 16, 2019 in United States
- Each item will fully occupy one Amazon locker
- Always keep track of how many remaining lockers are available after each API call| Report Duplicate | Flag | PURGE
- 1of 1 vote
AnswersAmazon has N buildings on the site, building ID ranged from 0 to N-1
- arpita.tanvi21 October 13, 2019 in United States
Every employee has an office space in one of the buildings.
Now employee may make a request to move from current building X to
another building Y. A moving request is noted by
Class Request{
String employee names;
int from building;
int to building;
}
Initially all buildings are full. A request from building X to building Y is
achievable only if someone in building Y made an achievable requests to
move away and therefore creates a vacancy
Given a wishlist of requests, help us plan for the best way of building
swaps. A plan that fulfill the maximum number requests is considered
the best
Output is a list of employee names on cyclic swaps.
For Ex:
Input :
List<Request requests{
<"Alex" 1, 2>,
<"Ben", 2, 1>,
<"Chris", 1, 2>,
<"David", 2, 3>,
<"Ellen", 3, 1>,
<"Frank", 4, 5>
}
Expected Output:
List<List>
[ ["Alex","Ben"],["Chris","David","Ellen"] ]
Can someone please help me how to solve this one?| Report Duplicate | Flag | PURGE
Software Developer - 0of 0 votes
AnswersSuppose two arrays are given A and B. A consists of integers and the second one consists of 0 and 1.
- AN October 11, 2019 in India
Now a operation is given - You can choose any adjacent bits in array B and you can toggle these two bits ( for example - 00->11, 01->10, 10->01, 11->00) and you can perform this operation any number of times.
The output should be the sum of A[0]*B[0]+A[1]*B[1]+....+A[N-1]*B[N-1] such that the sum is maximum
During the interview, my approach to this problem was to get the maximum number of 1's in array B in order to maximize the sum.
So to do that , I first calculated the total number of 1's in O(n) time in B. Let count = No. Of 1's=x
Then I started traversing the array and toggle only if count becomes greater than x or based on the elements of array A(for example : Let B[i]=0 and B[i+1]=1 & A[i]=51 and A[i+1]=50
So I will toggle B[i] B[i+1] because A[i]>A[i+1])
But the interviewer was not quite satisfied with my approach and was asking me further to develop a less time complex algorithm.
Can anyone suggest a better approach with lesser time complexity??| Report Duplicate | Flag | PURGE
Software Developer Algorithm - 0of 0 votes
AnswersWrite a method that merges a fixed number of streams containing an infinite sequence of monotonically increasing integers into an output stream of monotonically increasing integers. It is important to note that the input stream are infinite, so any solution based on the length of the streams would be considered incorrect.
Note that the question was given in the context of Java with the below code given as the base contract for the method.public void merge(List<Stream> inputStreams, Stream outputStream) { // Implement me }
This was also provided as the definition of "Stream" in this case, and not what is defined in java.util.stream.Stream.
- gr1ml0ck October 05, 2019 in United Statesinterface Stream { // Retrieves but does not remove the next item from the stream int peek(); // Retrieves and removes the next item from the stream. int poll(); // Puts an item into the stream void put(int i); }
| Report Duplicate | Flag | PURGE
Amazon Solutions Engineer Algorithm - 0of 0 votes
AnswersDesign a data structure for json objects. Json objects consist of key:value pairs. And here the value can be int, array or another json object.
- anonymous October 05, 2019 in India| Report Duplicate | Flag | PURGE
Adobe - 0of 0 votes
AnswersWrite test cases for earring with diamond, gold clamp, diameter 13mm, width 4mm
- roman.khomitsky19 October 05, 2019 in United States| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance - -1of 1 vote
AnswersGiven a set of horizontal and vertical line segments, find the number of squares formed by them?
- uj.us October 04, 2019 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersImplement union and intersection of two array(in a efficient way).
- dhruvjoshi43 October 04, 2019 in india for none
Additional information given by the interviewer was: elements of the two given array may be repeated but cannot be repeated in union and intersection array.| Report Duplicate | Flag | PURGE
Amazon Data Engineer test - 1of 1 vote
Answersfind nearest word from the given non-english dictionary which is one off character. (could be non ascii characters)
- prathji October 01, 2019 in United States
for eg. dictionary contains { apple, pineapple, banana, orange }
if given word "applx" then return true, as applx matches with apple and only one character is off.
aplpe returns false| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswerGiven a square (n x n) matrix which only contains 0 and
- danishm026 September 29, 2019 in India
1. Find the minimum cost to reach from left most column to rightmost column.
Constraints/rules:
a. Starting point: You can start from any cell in the left most column i.e. (i, 0) where i can be between 0 and n( number of rows/ columns)
b. Destination: You can reach any cell in the rightmost column i. e ( k, n) where k can be anything between 0 and n.
c. You cannot visit a cell marked with 0.
d. Cost is defined as the sum of cells visited in path.
e. You can move up, down, left and right but not diagonally.
For example,
take 2x2 matrix
1 | 0
1 | 1
One possible path is 00 -- 10 -- 11 with cost 3
Other one is 10 -- 11 with cost 2
so minimum cost on this case is 2.| Report Duplicate | Flag | PURGE
unknown Random Algorithm Data Structures - 0of 0 votes
AnswersWhat is the next number in the series 16,24,54,115
- sowmyapadi4444 September 23, 2019 in United States| Report Duplicate | Flag | PURGE
- 0of 0 votes
AnswersWhat is the next number in the series 76,24,54,115
- sowmyapadi4444 September 23, 2019 in United States| Report Duplicate | Flag | PURGE
- 0of 0 votes
AnswersDescribe the Flyweight and Visitor design pattern with example
- bharsaklemukesh975 September 22, 2019 in India| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Object Oriented Design - 0of 0 votes
AnswersYou have a vector of 128 floats (float data[128]) in shared memory, an environment with 8 threads and a convenient function called barrier() that will block on each thread until it will be signaled by all 8 threads (a simple semaphore of 8 elements).
- bharsaklemukesh975 September 22, 2019 in India
Write a pseudo-C parallel function that calculates the sum of all 128 elements storing it inside data[0]; the function can alter/destroy the content of the other 127 elements of data[].
thread_id goes from 0 to 7: it is constant and unique for each of the 8 threads.| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Operating System - 0of 0 votes
AnswersConsider the following 3D scene representing an old town's main square:
- bharsaklemukesh975 September 22, 2019 in India
• A single statue
o static geometry, high polygon count
o low complexity fragment shader
• A particle system simulating smoke
o animated, rendered as a large set of points
• A small set of characters
o animated geometry, medium polygon count
o medium complexity fragment shader
• A large set of buildings
o static geometry, low polygon count
o low complexity fragment shader
• A background image/skybox
• The camera/viewpoint is continuously moving within the scene.
How would you render the statue - by itself – using OpenGL to achieve maximum vertex performance (vertices/second)?
How would you render the particle system - by itself - using OpenGL to achieve maximum vertex performance (vertices/second)?
How would you render the scene - as a whole - most efficiently on a GPU using OpenGL?
Given that the 3D scene was being rendered correctly but that you wanted to improve the performance further, how would you determine if the main performance limitation/bottleneck was located in the application, in the vertex processing stage, or in the fragment processing stage?| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Graphics - 0of 0 votes
AnswersThere are cards and each card has an identity. e.g. HC1 has ID 1, this ID also represents the cost of the card. Your sister already have some cards and you want to gift her cards which she do not have already. Program is to return the max number of cards you can buy for her.
- acharyashailendra1 September 19, 2019 in India
Constraint : You have amount d, and want to buy as many distinct card as you can.
e.g. Sister Cards = [2, 3, 5], D : 7 Card you buy : 1, 4
Output : 2| Report Duplicate | Flag | PURGE
SDE-2 - 0of 0 votes
AnswersYou have been given a special and normal status of alphabets.
- acharyashailendra1 September 19, 2019 in India
e.g. “01111001111111111011111111” represents “abcdefghijklmnopqrstuvwxyz”. Here 0 represents normal character and 1 represents special character.
Given an Input String S and a number k, find the maximum continuous sub array with maximum k number of number elements. There is no constraint on special character.
e.g.
S = “giraffe”, K = 1, “011110011111111110111111”
Output : 3
How ?
normal characters : a, g, f
one of the possible solution : gir (as this has only one normal character)| Report Duplicate | Flag | PURGE
SDE-2 - 0of 0 votes
AnswerGiven a binary String which represents the target state. Minimum number of flips needed to convert a same size Binary String (with all 0’s) to target state. A flip also causes all the right bits to be flipped.
- acharyashailendra1 September 19, 2019 in India
e.g.
Input : 00101 (Represents Target)
Output : 3
Explanation :
00000 -> 00111 -> 00100 -> 00101| Report Duplicate | Flag | PURGE
SDE-2 - 0of 0 votes
AnswersGiven a level K , you have to find out the sum of data of all the nodes at level K in a binary tree. Input is given as:
- Notagoodcoder September 19, 2019 in United States
(P(C()())(C()())) P is for Parent, C is for child. if parent has one child : (P(C()())()) if parent has no child : (P()())| Report Duplicate | Flag | PURGE
Samsung - 0of 0 votes
AnswersCreate Valid html from below input.
- samfriendcom1234 September 18, 2019 in United States
String str="abcde"
points:- [{0,2,b},
{2,4,u}]
output : <b>ab<u>c</u></b><u>de</u>
Explanation:- character from 0 to 2 index should be bold, 2 to 4 index should be underline. Tricky point is that character at index 2 should be both bold and underline.| Report Duplicate | Flag | PURGE
xyz SDE1 - 0of 0 votes
AnswersN cows are standing at the origin on x-axis, each cow has some appetite, in other word hunger index. A cow can sleep of 1 unit of time or eat for one unit of time or move left or move right. There are some vessels placed on the x-axis, they are having infinite supply of fiod. Find minimum time in which all cows appetite would be filled.
- xyz September 15, 2019 in United States
Input:
cow Apetitte = {1,1}
Vessle locations = {-1,1}
Answer would be 2 since both cow can go in different direction they would eat for one seconds. One second for moving and one second for eating.
This problem looks to be similar to rotten eggs/tomatoes.| Report Duplicate | Flag | PURGE
Allegient SDE-2 Algorithm - 0of 0 votes
Answershow to find the fastest xor of large subarray or given range?
print(reduce(xor,arry[qury[1]-1:qury[-1]]))
but it's not working for larger input
- Dhioyt September 14, 2019 in United States| Report Duplicate | Flag | PURGE
HackerEarth
Open Chat in New Window