I just check out the CreerUp Website, most of the interview questions are interesting but hard to answer
As a programming starter who wants to enter IT field later, I need to check these questions!
Given a building of H number of floors and an elevator composed of N boxes such that only one box stops at a particular floor and that if a box stops at x-th floor than the box on top of that would stop at (x+d)-th floor for some constant d.
Given H and N, find the number of different elevator configurations. Two elevators are different if their bottommost box is at first floor than there exits an “i” such that a box is at i-th floor in one elevator and no box is at i-th floor in other elevator.
if H = 9 and N = 3, then there are 2 configurations possible.
1) First box stops at 1-st,2nd,3rd floor. Second box stops at 4-th,5th,6th floor and third box stops at 7th, 8th, 9th floor.
2) First box stops at 1st,4th, 7th floor. Second box at 2nd,5th,8th floor and third box at 3rd, 6th, 9th floor.
After some time thinking and reading comments for this questions, it seems that this problem is some kind of dynamic programming, based on the given example, I just figured out the possible configurations number must be related to the number of H/N. So I come out with a method like this:
(The possible configuration number should equal to number of factors of H/N)
configurationNum = 0
fixNum = floorNum/boxNum
for i in range(1,fixNum+1):
if (fixNum % i) == 0:
print 'Final: %s'%(getConfigurationNum(9,3))
Wish anyone knows the correct answers help me out with this problem.
What data structure would you use to implement spell correction in a document. The goal is to find if a given word typed by the user is in the dictionary or not (no need to correct it).
What is the complexity? What if you have to support multiple languages/dictionaries?
This question is more towards the data structure, I would like to use python again for it.
We all know in python, dictionary can be used as Hash or Tree data structure, and list can be used as stack.
The key points from wgx731
- List as stack for correction, as when we find a wrong spelling user may want to undo the changes to compare where the spelling is wrong.
- Dictionary of Dictionary to store all the correct words, for example, with multiple languages, we first categories by languages, then inside each dictionary we can categories by First letter, like what we do in real world dictionary.
- I need help on complexity, how is the memory usage? I have no idea.
Just a few comments, maybe I am not on the right track, feel free to help me out
What is the time and space complexity of Fibonacci series recursive function.
First, let’s review how to write a recursive function to calculate Fibonacci series.
if n == 0:
elif n == 1 or n == 2:
After that I read something about space complexity.
The space complexity of a program (for a given input) is the number of elementary objects that this program needs to store during its execution. This number is computed with respect to the size n of the input data.
It seems like number of if statements will affect time and number of the main calculation will affect complexity. Again, I haven’t dive deeply into what is complexity. Need Help here as well.
Check more at CreerUp Website. Wish you have benefited from reading this post. Thank you.