Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Assume you have a CustomList class, the list class has an array in it, it has one function fizz(n) that returns the first n elements in the array, it remembers the last index so it has the following outputs for the following inputs: CustomList(['a', 'b', 'c'])
cl.fizz(2) -> ['a', 'b']
cl.fizz(3) -> ['c']
cl.fizz(1) -> null
Now implement a SuperCustomLists class that you can add custom lists to, it should be able to remember the current list it's using, it should have a fizz(n) function and a del(CustomList cs) function. It should behave the following way assuming an instance contains the following custom lists ['a', 'b', 'c'], ['d', 'e']
scl.fizz(4) -> ['a', 'b', 'c', 'd']
scl.fizz(2) -> ['e']
scl.fizz(1) -> null -
Constraints
Objective: Make fizz O(n) and del O(1) preferably (my best solution has this O's if you can do it better then disregard), you can't peek inside the arrays, you can't change the input params for the functions (i.e del must accept an instance of custom list), if you remove the current list for the next fizz start at the next one. Start by developing fizz. -
asgs112753yFor the del, I would maintain a map of hashes and keep updating it as and when fizz is invoked on the main super list
-
@asgs it’s a way but you would need to keep the map and the list sync’d and might get cumbersome
-
asgs112753y@JKyll I am not sure about the cumbersomeness. Removing/accessing the hash entry of this list from the map is O(1). To avoid the left shift of the array elements in the list, the list itself could be marked as -1 for future skipping. It would make fizz O(n+k), k being lists deleted
How did you implement this? -
@asgs you can store the reference of your current list that way you can ignore depleted lists, I don’t want to spoil it but the way I did it with a scripting language was using a map and references. Think about a linked list. At least that was my best attempt wasn’t allowed to do it at the interview 🤷♂️
-
@JKyll Ken. The list *class* has an array in it? So is this a static array, or am I misunderstanding and this is an instance variable?
-
@Wisecrack yeah it’s an instance variable, it’s set on the constructor function and passed as an argument. The point is you can only interact with the class through the fizz function
-
Fransen162yThe picture shows all of me. When I went in for a quick fix of a few lines of code. I ended up breaking the whole program.
Related Rants
-
Coffe2Code37HR: How many years you've been developing on Android ? Me: Two years, with many projects on my own. HR: So, ...
-
salimansari19Job offers be like: We need a VIRGIN with atleast 2 years EXPERIENCE of SEX...
-
brod20Recruiter: And I found your devRant account, it’s @brod right? very interesting stuff. Me: ...
- Get invited to apply to job
- Technical interview, guy shows up late starts small talk wasting time and gives me the exercise
- Start implementing the first algorithm, finish it passing min test cases then realize there's a solution that would make both algorithms a breeze
- I pitch my solution realizing there's no much time left, cuz we lost almost 20 min of my test hour talking about BS plus the almost 10 min he arrived late, and reassure the interviewer it can be developed faster
- Interviewer says it doesn't matter, we should finish edge cases
- Kay no problem, finish the first algorithm successfully and explain pitfalls on the second part with the current implementation
- I tell him there's a better solution but he doesn't seem to care, he says time's up
Now here's the funny part.
I get called by the recruiter today (2 weeks later) and she says "They are happy with your soft skills but feel there are some gaps with your coding, they would like to repeat the technical interview because they didn't feel there was much time to assess the 'gaps' ".
Interviewers, either I'm competent enough to work for you or not, your tests must be designed to assess that, if you see you can't fit the problem you want in the time you have left change the problem, reschedule or here's an idea...LEAVE THE BS CHITCHAT TILL THE END AND START THE INTERVIEW ON TIME. When I do interviews I always try to have one complete free hour and a one algorithm exercise because I expect the candidate to solve it, analyze it and offer alternatives or explain it, I've never had someone finishing more than 2 an hour.
You can keep your job I'll keep my time. I'll write a similar problem on the comments to pass on the knowledge for people who enjoy solving these kinds of problems, can't give you the exact same thing, also tip guys don't do NDA's for interviewing it makes no fucking sense trust me no one cares about your fizz buzz intellectual property.
rant
technical interview
recruiters
job interviews
jobs