Software Engineer / Developer Interview Questions
0of 0 votesHow do you add up a very long list of numbers multiple threads (100 threads?) How many cores do you require?
How do you increase the performance of this program? Does the number of threads created get limited by the cores of the box? How exactly are you gonna delegate it to the cores? (as in- these number of threads need to use core#1, and so)
0of 0 votesYou are given a set of integers and you are also allowed to apply sign change operation on all elements. Write an efficient algorithm to find minimum Sum. The minimum Sum should be greater than equal to zero. e.g. if Set is { 2, 1, 3, 4, 2 } Minimum Sum is 0 since you can modify the original set as { -2, -1, -3, 4, 2 }
The input begins with n (the number of integers in the set) followed by n integers. Input ends when n is 0.
For each test case please output the answer in a separate line for each value of n.
Bounds :
0 < n <= 1000
sum of the following n numbers <= 100,000
0of 0 votesWrite implementation of PIVOT keyword found in SQL server.
1of 1 voteHow will you store a million phone numbers in a space efficient way?
-8of 10 votesInput is a number of words. Construct a listing of valid 6-letter words. You have access to bool IsValid(const string& word); Implement Insert() and Get() for this listing.
0of 0 votesGiven coordinates (X[i],Y[i]) of all the cities in the world(for simplicity lets consider we have 2D world map). You are given a user's location (x,y), find out the closest city to the user. Write code for it.
Update:
Time complexity of the solution should be better than O(n) as there will be multiple lookup queries with different input points.
You can preprocess the data in any way you like, but you need to minimize the query execution time complexity.
1of 3 votesThere is an old dry well. Its sides are made of concrete rings. Each such ring is one meter high, but the rings can have different (internal) diameters. Nevertheless, all the rings are centered on one another. The well is N meters deep; that is, there are N concrete rings inside it.
You are about to drop M concrete disks into the well. Each disk is one meter thick, and different disks can have different diameters. Once each disk is dropped, it falls down until: * it hits the bottom of the well; * it hits a ring whose internal diameter is smaller then the disk's diameter; or * it hits a previously dropped disk. (Note that if the internal diameter of a ring and the diameter of a disk are equal, then the disk can fall through the ring.)
The disks you are about to drop are ready and you know their diameters, as well as the diameters of all the rings in the well. The question arises: how many of the disks will fit into the well?
Write a function:
class Solution { int falling_disks(int[] A,int[] B); }
that, given two zero-indexed arrays of integers − A, containing the internal diameters of the N rings (in top-down order), and B, containing the diameters of the M disks (in the order they are to be dropped) − returns the number of disks that will fit into the well.
For example, given the following two arrays:
A[0] = 5 B[0] = 2
A[1] = 6 B[1] = 3
A[2] = 4 B[2] = 5
A[3] = 3 B[3] = 2
A[4] = 6 B[4] = 4
A[5] = 2
A[6] = 3
the function should return 4, as all but the last of the disks will fit into the well. The figure shows the situation after dropping four disks.
Assume that:
N is an integer within the range [1..200,000];
M is an integer within the range [1..200,000];
each element of array A is an integer within the range [1..1,000,000,000];
each element of array B is an integer within the range [1..1,000,000,000].
Complexity:
expected worst-case time complexity is O(N);
expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Elements of input arrays can be modified.
0of 0 votesGiven a sorted array of size N and a sorted array of size M+N, merge the first array into the second preserving order. There is enough space in the second array to hold all elements from the first one.
1of 1 voteAn array contains two sub- sorted arrays. Give an inplace algorithm to sort two sub arrays.
for ex: I/P: 1 4 5 7 8 9 2 3 6 10 11
O/P: 1 2 3 4 5 6 7 8 9 10 11
2of 2 votesReturn a shortest prefix of <code>word</code> that is <em>not</em> a prefix of any word in the <code>list</code>
e.g.
word: cat, it has 4 prefixes: “”, “c”, “ca”, “cat”
list: alpha, beta, cotton, delta, camera
Result is “cat”
0of 0 votesImplement memcpy function which accepts num of bits as argument as oppose to number of bytes.
memcpy (src, dst, num_bits)
1of 1 voteArrange 1 to N in random order with no duplication.
1of 1 voteGiven a array of numbers and a number N. Find out all combinations of 3 numbers in array whose sum is N.
Genarally, there is a common similar problem to find all possible pairs whose sum is given number. Now the problem extention to this. Find all possible 3 numbers whose sum is given number.
0of 0 votesWhats the best way to synchronize Singleton class.
0of 0 votesHow will you synchronize 3rd party library from your application..
1of 1 voteSuppose we use binary search tree to implement set, design an algorithm that we can get an random element from the set, while maintain all the other set operations have same complexities.
-3of 3 votesif u have singleton class n war file and two application are acceing the war file what wil hapeen to that singleton class.....ans - some class loader concepts.
-3of 3 voteshow wil u use the lock mechanism in java
-2of 2 voteswhat will happen if u build code on java 16 and put on machine with java 15
0of 0 votesExplain exceptions in java..what is base class of exception...what does error class do..what does runtimeexpception class do
1of 1 voteDifference between thread and process
1of 1 voteExplain how hashtables work internally. How is hashcode generated and what wiill happen to hash code when 2 values are same.
-2of 2 votesThere is a class called A, which receives co-ordinate (x, y) which is processed in a function called fn(x,y): produces an address in memory, pass that address to B and then B retrieves data from memory at that address and then sends that data back through two 32 byte (total 64 byte) data chunk to users. Design the class. follow up questions: How to improve the functions. What are the main bottlenecks?
0of 2 votesthere are 5 stairs. you can take either 1 or 2 steps
how many combinations you can take to climb the stairs?
0of 0 votesWrite a program to find the first occurance of one string into another : it is okay to write a O(n2) algorithm
2of 2 votesWrite a program to print the powerset.
E.g. given this set {1,2,3}, it will print {},{1},{2},{3},{1,2},{1,3}, {2,3}, {1,2,3}
-1of 3 votesWrite a program to clone a graph
2of 2 votesGiven an array of 0s and 1s, find out:
1. all the subsequences where number of 0s = number of 1s
2. max length subsequence where number of 0s = number of 1s
Update:
We need to find subarrays, not subsequences. Sorry for the confusion.
1of 1 voteGiven a function
float convex(float x)
WAP to find the minimum value of convex() between x1 and x2. convex is first monotonically decreasing and then monotonically increasing between x1 and x2.
float minima(float x1, float x2)
0of 0 votesIn a pocket calculator, a person is randomly typing a 8 digit number. What is the probability that the number looks the same even if the calculator is turned upside down.
