Principal Software Engineer Interview Questions
- 0of 0 votes
AnswersDesign a distributed key-value store that can perform the following
- neer.1304 May 27, 2020 in United States
Store a set of attributes (value) against a particular key (k)
Fetch the value stored against a particular key (k)
Delete a key (k)
- Perform a secondary index scan to fetch all key along with their attributes where one of the attribute values is v.
Key can have a value consisting of multiple attributes.
Each attribute will have name, type associated (primitive types - boolean, double, integer, string) & type has to be identified at run time.
Ex -
1) Key = delhi has 2 attributes ( pollution_level & population)
2) Key = jakarta has 3 attributes (latitude, longitude, pollution_level)
3) Key = bangalore has 4 attributes (extra - free_food)
4) Key = india has 2 attributes (capital & population)
5) Key = crocin has 2 attributes (category & manufacturer)
Example of Secondary index:
Get all keys (cities) where pollution_level is high. Get all medicines by manufacturer (GSK)
So, in a nutshell, value must be strongly typed when defined.
Attribute
1. Attribute is uniquely identified by its name (latitude, longitude etc.
2. Data type of the attribute is defined at the first insert. (i.e. data type of pollution_level is set when key = delhi is inserted)
3. Once data type is associated with a particular attribute, it cannot be changed.
(i.e. free_food when defined takes type = boolean, hence, any key when using the attribute - free_food must allow only boolean values on subsequent inserts/updates)
Non-functional requirements
Highly scalable - Support for high throughput with very low latency
Highly available
Shared nothing architecture i.e. Support for Multiple nodes and each node is independent & self-sufficient.
Stretch - Smart client i.e. clients being aware of available servers & makes smart routing based on that available information.| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Computer Architecture & Low Level - 0of 0 votes
AnswersDesign and implement following . Suppose have 10 resources and 5 threads how do you design so that threads asking for
- pgopan.hai November 10, 2018 in United States
Resources should be done in order. Eg t1 asks for 3 resources, t2 asks for 4 resources…| Report Duplicate | Flag | PURGE
Cadence Inc Principal Software Engineer Threads - 1of 1 vote
AnswersGive a string [] words,
- ajay.raj January 26, 2018 in United States
Find the shortest string [] containing the keyword inside.
example:
words: sky cloud google search sky work blue
keywords: sky blue
return: sky work blue| Report Duplicate | Flag | PURGE
Google Principal Software Engineer - 0of 0 votes
AnswersI was asked this question for the above role:
Create a fixed size cache which is fully associative. The entries are evicted based on the rank. for any entry added, the function int getEntryRank(entry) will return its rank which will not change on lookup
db_read_entry() to get the entry from db
Part 2) The rank will change on lookup
- ali.kheam July 28, 2017 in United StatesMy solution was: a hashtable (unordered_set<entry>) and a priority queue <pair<int, entry> > lookup(entry) { hashtable lookup. if found, return the entry (O(1)) // otherwise (not found) if limit reached, then // evict the priority queue top, entry e = db_read_entry(); // expensive op //insert the entry into the hash set, //insert pair<int, entry>(get_entry_rank(entry), entry) into the priority queue. (O(logn)) return entry; } Part 2: The rank change on lookup Since the priority queue does not provide the key(hash key) value to be modified, and only provide access to top entry. I propose change in the associated ds for hashset, My proposal was: create an associated binary tree(std::set) with the hashmap (map of entry as key, and the iterator entry in the std::set of entries) . I used iterator to avoid look up for entry into the set during each entry lookup in the hashset. The set contains the [rank information + entry]. On look up, the entry into the set(of rank) is looked up (O(1)) and then erased, and then insert back after recaulated rank value.The iterator inrto the hash_set is also updated with this new iterator. On limit reached, the tree is searched for min value. from that min value item (the rank and the entry), the entry is looked up into the hash_set, and hence removed from there too. The rest of the process is the same as lookup as described below. I believed my slution was faor enough O(1) look up, if not found. the look up (with const rank) O(logn) + db access time. db access time dominate the O(logn) hence this logn (to insert into the priority queue,(or pop and insert into the priority) does not matter For changing rank: The binary tree lookup (O(1) since the hash_map has the iterator update of the rank, (lookup and removal of the rank entry in the binary tree O(1), and insert is O(logn). Hence each operator (lookup, evict and lookup, excluding the db access) will take O(logn) instead of O(1). I was rejected because of not optimize solution (performance is not good). I am wondering whether the solution was not good even though it was phone interview and I have to work within the time frame of 25 minutes. or the interview process is just unrealistic. Please share your solution so that I can see where I failed
| Report Duplicate | Flag | PURGE
Principal Software Engineer Data Structures - 0of 0 votes
AnswersThere is a Deployment Window of fixed time T. There are multiple patches (independent of each other),
- LateRunner March 07, 2016 in India
that are to be deployed in the fixed time T. Find solution to deploy patches such that maximum time is
utilized in the window.
Test Case 1:
Input:
Window Size 4, List of Patches: [1,1,1,2,3]
Output:
[3,1] or [1,1,2]
Test Case 2:
Input:
Window Size 5, List of Patches: [1,2,3,6]
Output:
[2, 3]| Report Duplicate | Flag | PURGE
Computer Associates Principal Software Engineer Algorithm - 1of 1 vote
AnswersDesign whatsapp like app. Focus on scallable issues.
- karni.fazil February 14, 2016 in India| Report Duplicate | Flag | PURGE
Principal Software Engineer - 0of 0 votes
AnswersDesign Game. Focus more on classes involved and make it online game.
- karni.fazil February 14, 2016 in India| Report Duplicate | Flag | PURGE
Principal Software Engineer - 0of 0 votes
AnswersGiven a table with id and value ,
- Engineer1111 February 11, 2016 in United States
======
id value
======
101 100
102 150
101 80
101 200
102 120
======
Find the median value using SQL. Goes without saying that you can't use MEDIAN function of Oracle SQL.
output:
101 100
102 175| Report Duplicate | Flag | PURGE
Principal Software Engineer - 3of 3 votes
AnswerDesign Uber or Lyft like architecture keeping scale, latency and availability in mind. The design can be at macro level first, that is, major components like persistent store (SQL/NoSQL/redundant), cache, communication/messaging. The design and if time permits, details will then be discussed/challenged.
- Blue Ocean November 29, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Distributed Computing - -1of 1 vote
AnswersExplain all Design Patterns Used in Java Spring Framework.
- vikrantgupta01 September 27, 2015 in India| Report Duplicate | Flag | PURGE
LendingKart Principal Software Engineer design - 0of 0 votes
Answers// Given the root node of a tree in which each node can contain ANY number of chidren (i.e. NOT binary, unbalanced), find the level in the tree with the most nodes
- kaushikjp August 03, 2015 in United States
/*
A Level 0
/ \
B C Level 1
/|\ ||
abc ef
Answer: Level 1| Report Duplicate | Flag | PURGE
Symantec Principal Software Engineer C++ - 6of 8 votes
AnswersGiven an unsorted array of natural numbers. Where numbers repeat in array. Out put numbers in the order of frequency. Where number of out put is passed as parameter.
- dreamchaser1984 March 25, 2015 in United States
For Ex:
Array -> [0, 0, 100, 3, 5, 4, 6, 4, 2, 100, 2, 100]
n -> 2
Out put -> [100, 0] or [100, 2]
Since 100 is repeated 3 times and 0, 2 is repeated 2 times, out put up to 2 most frequent elements, program should out put either 100, 0 or 100, 2| Report Duplicate | Flag | PURGE
Google Principal Software Engineer Algorithm - 0of 0 votes
AnswersWhen a Synchronied method is executed in a Java class, which Object is getting locked ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswersHow does URL shorteners ( like bitly etc ) work ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Algorithm - 0of 0 votes
AnswerHow write your own annotations in Java ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswerIn JDBC, When you do the following
Class.forName("driver class name") Connection conn = DriverManager.getConnection()
How does JVM recognizes to give the exact driver's connection object which has been loaded by Class.forNAme in the previous line ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswersWhat is dependency injection and Inversion of Control in Spring ?
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswersGiven an input Array which contains elements as below
- vinodjayachandran March 21, 2015 in India
[a1,a2,a3,....an,b1,b2,b3,...bn]
Output Should be
[a1,b1,a2,b2,a3,b3,.....an,bn]
Do it without any additional Memory.| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Algorithm - 0of 0 votes
AnswerIn Java Threadpool Executor, what are the possible rejection policies if all the threads are used.
- vinodjayachandran March 21, 2015 in India| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Java - 0of 0 votes
AnswersAssume a Bank Branch, with few teller counters.
- vinodjayachandran March 21, 2015 in India
There is a token system, from which customers can procure tokens for the type of transaction (cash withdrawal, cheque deposit, account opening, loan etc).
Each teller needn't have the capability to handle all possible types of transactions. each Teller can handle only a subset of transactions and there could be a overlap of transactions handling capabilities between tellers.
Design this banking system such that, each customer is served on a first cum First serve basis as per the token number for each transaction type.
Hint : Publisher-Subscriber Model| Report Duplicate | Flag | PURGE
Blue Jeans Principal Software Engineer Algorithm - 3of 3 votes
AnswersFind popular item in sorted array of natural numbers.
- dreamchaser1984 February 25, 2015 in United States
An item is popular is if its repeated n/4 times or more.
For Ex:
Input: 123444445678
Popular item is 4.
Liner scan is O(n), but solution needs to be in O(logN) complexity and O(1) space complexity.| Report Duplicate | Flag | PURGE
Google Principal Software Engineer Algorithm - -1of 1 vote
AnswersForm Tree from following data
- itnilesh October 06, 2014 in United States
I have data like this
6 has parent SET 5,4
5 has parent SET 3,4,1,2
4 has parent SET 2,1,4
3 has parent SET 2,1
I need to create tree like
1 --> 2 --> 3 --> 4 --> 5 --> 6
OR
2--> 1--> 3--> 4-- >5 --> 6
Because there is no enough info about 1-->2 or 2--> 1| Report Duplicate | Flag | PURGE
Symantec Principal Software Engineer Algorithm - 0of 0 votes
AnswersHow does one application implement similar to DropBox? How can we Mmake sure they are in sync for files. How u’ll check for files are downloaded. How u’ll download files. What protocols u’ll use?
- newbee September 02, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Knowledge Based - 0of 0 votes
Answershow to use perl to write a script to deal with the comments in a C++ file?
- holmespanda June 06, 2014 in United States
let's say a file a.cpp, and it contains several comments. You have to remove the comments.
we know that in C++ there two kinds of comments // and /* */
i was trying to use the regex, but later i was stuck when i found that these comments can appear in a string, say "aaa // bbb", then it will be another situation.
can someone help me with this case?
any ideas will be helpful.| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Perl - 0of 4 votes
Answers2 players place the knight in his desired postion (input taken from user) on chess board.The knights move in valid knight postions in chess.2 knights move one after the other.game ends when any one knight reaches bottom right corner.
- abcd March 10, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Algorithm - 2of 2 votes
AnswersYou are given an array with numbers - [11, 3, 11, 11, 3, 2, 0, -2, 2]
- KevinK February 27, 2014 in United States
You are supposed to write a function that returns the number that appears "odd" number of times.
The solution is obviously using HashMap. But that takes O(n) to create the HashMap and O(n) to lookup. How can one eliminate the second O(n) yet keeping the HashMap?
Hint: Do you really need to count frequency of occurrence of each digit?| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Arrays - -1of 1 vote
AnswersWhat happens when you type a link in any browser and click GO button? List all steps.
- KevinK February 21, 2014 in United States
What should be the issue if the browser app build that i have today is 1 second 250 milliseconds slower than yesterday's build? ASSUME: WiFi is perfect, loading 10 webpages from a controlled server - hence there are no infrastructure or server side delays causing this.
What would you think might be the issue? How would you debug?| Report Duplicate | Flag | PURGE
Google Principal Software Engineer Debugging - 0of 0 votes
AnswersYou are given a string FOOFIGHTERS. You have to come up with an algorithm that will compress this string.
- KevinK February 21, 2014 in United States
You also have to make sure that you are not using extra memory. For example: FOOFIGHTERS will be compressed as FO2FIGHTERS. You should not use another array or bitfield to keep a frequency count for the individual letters.| Report Duplicate | Flag | PURGE
Google Principal Software Engineer Algorithm - 0of 0 votes
AnswersFind duplicates in a unsorted array and keep the order of integers as it is.
- HadoopUser December 25, 2013 in India| Report Duplicate | Flag | PURGE
Expedia Principal Software Engineer Data Structures