Forum Posts
1 Answer globally unique identifier(GUID)
how to generate GUID in c/c++
- coder September 07, 2018| Flag | PURGE 0 Answers Conversion of Java to C++
How can I convert Java source code into C/C++?
- suhara July 13, 2018| Flag | PURGE 0 Answers Conversion of Java to C++
How can I convert Java source code into C/C++?
- suhara July 13, 2018| Flag | PURGE 0 Answers Running time for a video question
Hi all,
- iosdevresume July 13, 2018
On one of the video Gayle presents the following problem -
"Given p number of people with their birth year and their death year, return the year with the maximum population".
At the same video she also states the best possible solution is O(P+Y) s.t. P is the number of peoples and Y is the length of the array of the years from the minimal birth year to the maximal death year, Can't the optimal solution be O(P)?
Here's how -
Generally she achieved a solution of O(P+Y) since she iterate through all the peoples in the input getting the minimal year and the maximal year that is O(P) which gives her Y the total number of years all the people was living in, then she instantiate an array on the size of Y that is O(Y), then she goes through every person in the input, add +1 for birth and -1 for deaths so that is O(P) and lastly she goes through all the array of years summing up the number of +1\-1 to that point which is giving her the number of people living in that year so again O(Y), all together it's O(P+Y+P+Y) => O(P+Y)
However - using a TreeMap (a hashmap that uses an inner tree to sort the dataset) we can achieve O(P), here's how -
traverse the people input and for every person p on the people list add +1 for the person birth year and -1 for the person death year that will end up with a tree with total (MAX) of 2*p nodes and traversing the tree to every year can yield that same result as traversing an array on the size of Y (however using a tree with 2p nodes is much memory efficient than using an array with potentially a-lot of unused 0's) while traversing the tree we can also keep int max which is the year with the max alive people in it.
Isn't that a better solution? or am I missing something?| Flag | PURGE 0 Answers Implement a rate-limiter-like iterator and how to improve the space complexity
Given a <Word, TimeStamp> pair data type iterator as input. Implement an iterator based on it which can ignore the item if the same word has occurred in the past 10 seconds.
- sun2gz July 05, 2018
My implementation is to use a HashMap to memorize the word and its latest timestamp + 10s. For each new item, it will be checked against the HashMap to see if it has duplicated word occurred in the past 10s.
The interviewer asked me how to improve the space complexity if the string value varieties are infinite. He mentioned some boundary stuff.
Could anyone share some thoughts?| Flag | PURGE 0 Answers Linked List addition with reversal, Google Interview
Given 2 Linked Lists containing single digit as data representing number with most significant digit at head and least significant at the tail return the addition of both.
- niklabh811 June 21, 2018
The solution must not reverse the given linked lists and do it in O(n) time complexity and constant space complexity(Recursive solution will take O(n) space because of stack).
For example:
9 -> 3 -> 2 -> 2 ->
+
3 -> 4 -> 8 -> 3 ->
=
1 -> 2 -> 8 -> 0 -> 5| Flag | PURGE 0 Answers Question
Take as input N, a number. Take N more inputs and store that in an array.
- Sagarshvn June 16, 2018
a. Write a recursive function which counts the number of ways the array could be split in two groups, so that the sum of items in both groups is equal. Each number in the array must belong to one of the two groups. Print the value returned.
b. Write a recursive function which keeps track of ways an array could be split in two groups, so that the sum of items in both groups is equal. Each number in the array must belong to one of the two groups. Return type of function should be void. Print the two groups, each time you find a successful split.
Input Format:
Take as input N, a number. Take N more inputs and store that in an array.| Flag | PURGE 0 Answers Error in 6th Edition
Maybe you fixed this already in 7th.
- timcrall January 09, 2018
In 6th edition, question 4.11, the question only specifies a binary tree but the answer assumes a binary search tree. Which is exactly a thing you told us to look out for. So I was.
EDIT: Although this doesn't really seem to affect the answer.
Also, for the love of all things holy, invest in some spam-blocking on the forums!| Flag | PURGE 0 Answers String Transformation
You are given 2 Strings A and B. You have to transform A to become B.
- anuj January 07, 2018
Following are the type of transformation possible:
1. pick an alphabet and replace all occurrences of this alphabet in the string by the next alphabet in the sequence[a,b,c,d----y,z]. Note that the next alphabet for z is a. The whole operation counts as one operation with Cost C is given as input.
2.pick an alphabet and replace all occurrences of this alphabet in the string by the previous alphabet in the sequence[a,b,c,d----y,z]. Note that the next alphabet for a is z. The whole operation counts as one operation with Cost D is given as input.
You have to return the minimum cost to transform A to B. if it's not possible return -1
Example:
A: "ab"
B: "cc"
C:2
D:5
Answer : 4
we need two C operations "ab" -->"bb"-->"cc"
Note that the last step of converting all b to c counts as one operation| Flag | PURGE 0 Answers Didn't receive any offer
Hi,
- stan.alexandru.dan November 30, 2017
I've held the interview process at Amazon for a position in one of the european offices.
So I got contacted by a recruiter, I did an online test, afterwards a phone interview, after that on-premise interviews.
I had 4 on-premise interviews, each a one-on-one with a Software Manager, 2 of them were algorithms, 1 was architecture and another was Software Design.
After 2 weeks I received a call from the recruiter. She told me I've passed the interview process, but there was predicament and I will not be receiving an offer from the center I applied to, and I will receive an offer from another european office on the same day.
3 months have passed, I haven't received any offer and the recruiter stopped responding, I have sent several mails and still no reply.
I still don't know what happened, my resumee wasn't that good, was my application lost in the process.
I don't know if it's worth trying again, if things like this happen. I know I've spent a full month, preparing, not sleeping well. I've never felt prepared for the interviews, also I wasn't outstanding on them, going through that again seems a bit much.
What do you guys think, should I try again, has anyone else had the same experience?| Flag | PURGE 0 Answers Developing Java game
creating a RESTful service using which players can play a simple game described
- stallapp November 02, 2017
below.
The game should have the following rules:
• The player has an infinite amount of coins.
• The player bets 10 coins to play a normal game round.
• In any round (free or normal), the player has a 30% chance of winning back 20 coins.
• In any round (free or normal), the player also has a 10% chance of triggering a free round where
the player does not have to pay for bet. The free round works in the same way as a normal round except
it costs 0 coins. The free round should follow immediately after the normal round.
• The player can both win coins and free round at the same time.| Flag | PURGE 0 Answers rejected by amazon for no reason
got rejected, I think I did well for all rounds, maybe not behavioral questions. They didn't give any feedback.
- ly October 21, 2017
the questions were not hard at all.
one round, I only got asked behavioral questions for 45 mins. really not that much to say
disappointed| Flag | PURGE 0 Answers Data Structure and Search Design
Question:
- Learneralways August 18, 2017
You are given an information on Cat object such as name,height and weight. For eg following:
String[] names = {"a","b","c","d","e","f","g","h"};
Integer[] height = {31,24,67,12,45,21,31,12};
Integer[] weight = {120,124,160,130,175,120,124,142};
You have to write a method which takes the following input and return the list of Cat objects which satisfies the input criteria. For eg
searchCriteria could be : HEIGHT or WEIGHT
searchValue could be : Integer value of either HEIGHT or WEIGHT
symbol could be : "<" , ">", or "="| Flag | PURGE
Open Chat in New Window