ShopeePay

Interview started off with a leetcode medium question, 79. Word Search. Interesting note is that the interviewer did not care about my thought process and did not answer my questions when i asked him, I needed to ask him several times to get a response. I did not manage to solve the question, mainly because the error stack trace was so long that I could not see what went wrong. However, the interviewer mentioned that he was more interested in the second part of the interview.

In the next section, the interviewer asked me deeply about my time at foodpanda, in the wallet experience squad. He was highly interested in pandapay. He asked me how the backend of pandapay was like, and expected me to explain it in full detail. He also asked me about how is the payment process like, with 3DS and stuff. He also asked me how is payment by QR code done, and the steps, which I have no idea.

The interviewer also asked me to design several API endpoints for payment handling, and asked me how to handle the case where there may be duplicate/concurrent payment requests.

Learnings:

  • During my foodpanda intern, I should have went deeper into the backend and find out how everything works, and not be siloed to the project that I was assigned to
  • Should have found out how the 3DS payment process works
  • Should have found out how payment by QR code works
  • Leetcode was an issue too, mainly i think i did not do backtracking properly, my visited set did not update properly

Data Infra

Round 1

When the interviewer joined, he starting speaking in chinese which I was taken aback by. Only after saying a few sentences in chinese, he asked if i was okay with him speaking chinese, which I replied that I was ok, but I will speak in a mix of english and chinese, but I am fine with him speaking chinese. He asked me to then introduce myself and my projects and internship experiences.

He seems highly interested with my experience with Kafka at Ascenda. He asked me deep technical questions about Kafka.

  • Why is Kafka so scalable?
    • Which i think i answered well
  • What happens when there is only one partition and multiple consumers?
    • I answered wrongly as I wrongly thought that all the consumers will consume from that partition, but in fact only one consumer can
  • How the offset in consumers work?
    • I did not give a good answer, I believe the answer he was looking for is that consumers belong to a consumer group, and if one consumer from that consumer group consumes a message, the offset for all the consumers in that consumer group will increase. So it ensures that different consumers in one consumer group do not consume the same message, but other consumers in other consumer groups can consume the same message.
  • What happens when there are multiple partitions but only one consumer?
    • I answered wrongly as well, similar to the previous question, the consumer will only consume from one partition

Afterwards, he asked me some database related questions, such as what’s the difference between parallel and concurrent.

  • What are the 4 levels of isolation?
  • What is the difference between SQL and noSQL?
  • How is sharding done in SQL?

Afterwards, he asked me some questions with relation to general knowledge questions.

  • What are some design patterns I used in my previous interns
  • What is the most technical challenging problem you solved in your interns
    • Interestingly, when I mentioned about the challenge of frontend polling the backend for updates, he mentioned why I did not use websockets (which enables for 2 way communication)
  • What is your opinion of Ruby vs Java
    • I mentioned that I like java more as it is typed, and Ruby has a global interpreter lock (GIL), which prevents for multi-threaded ruby
  • How to design a good API?
    • Interesting question, which I might have answered it a bit out of point. I mentioned about using the correct communication, eg. REST or GraphQL or gRPC
    • I mentioned how gRPC is good for backend machine to machine communication as it is sharing types

Learnings:

  • Should have read up more on Kafka, especially the handling of kafka for the edge cases
  • Should have known about how is sharding done, I thought doing it in SQL is hard, but I wrongly mentioned why. Sharding while maintaining availability during the period is tough.
  • Failed to mention and explain design patterns
  • The use of websockets for 2 way communication

Round 2

The interview started with a leetcode easy question. The question was to find the first unique letter. So for example, in the string “hello”, “h” is the expected output. I gave several ideas.

  1. We convert the string into a frequency dictionary, mapping letter to frequency in the string. Then we iterate through the string and find one that frequency is 0. Runtime: O(n) Space: O(n)
  2. We can also sort the string first then, then make use of 2 pointers to check if a character is unique or not Runtime: O(nlogn) Space: O(1) I initially assumed that solution 1 was too easy, so I went ahead to implement solution 2, as space complexity is O(1). However, the interviewer stopped me and said that we should prioritise runtime complexity and not space. I went ahead to implement solution 1 very quickly. However, during the implementation, I realised that the question wanted the first unique character and not just any unique character. However, luckily in python, even though a dictionary is not ordered, the default order of python dictionary is in the order it is inserted. Thus, when we iterate through the dictionary, the first character that has a frequency of 1 will be the answer we want. In any other languages, we will need a priority queue (hmm but then runtime will not be O(n))

Afterwards, the interviewer asked me a pretty hard question.

If u have 4 billion integers, and 1 GB of memory, and you want to find the existence of a number inside that 4 billion, how can you do it in the most efficient way possible?

I was initially taken aback, as I initially thought that this was a system design question. But it was actually some data structure question. I repeatedly asked her about the bounds, whether I have access to other computers etc. I also had trouble with the math. Here is the correct math: We have integers, each integer is 32 bits, or 4 bytes. So to load all these 4 billion integers into memory we need a RAM size of of RAM. This is definitely not enough given the 1GB of memory we have. One possible solution is using a bitmap. In a bitmap, we represent each of the integers as a bit, 1 indicating that it is present and 0 otherwise. So we only need , and it will work. Side note: A friend mentioned this solution, and the interviewer asked for more solutions, so there seems to be more than one solution.

Next, we moved on to the next section where she tested me on linux commands

  1. How to change directory
  2. How to create directory
  3. How to create an empty file
  4. How to fill that empty file with content
  5. How to search for a specific term inside the file
  6. How to count the number of lines in that file

I managed to answer 1-4 well, but for 5, I mentioned that we could vim inside the file and use the vim search to find the keyword. I know that this is not ideal, grep would be a better answer, but I forgot the syntax. I also mentioned that for 6, we could create an inline python script to find the number of lines even though I know that there is a command to find the number of lines easily but I forgot.

Next we moved on to the database portion. She gave me an example database tables filled with example data. She asked me to give the output when executing right join, left join and normal natural join. Interestingly after I provided her with my answers, she questioned me and asked me if what I did was correct (are you sure there are 2 rows here?), turns out she was just testing how confident I am with my answers, which I failed lol…

Next she asked me some quick fire CS fundamentals questions. She asked me what is the difference between ArrayList and LinkedList in Java. I mentioned that in arrays, we can get O(1) access, but with linked list, we need to iterate through the list just to get an element, so O(n). I also mentioned that when deleting an element both require O(n) time, as we need to find the element to be removed in linked list, and in array list when we remove an element, we need to move all the other elements up. She then mentioned, “oh so array list is always better than linked list?”, which I said no, because we can pair linked list up with another data structure like a hashmap, which maps the value of a linked list node, to the node. So we can get O(1) access, and then we can do removals of a node fast, in just O(1) time using pointers. Not sure if that is all the differences she was looking for tho.. She also then moved on to ask me about concurrency in databases. She asked me how do I handle the case when there are multiple threads or workers that are modifying the database. I mentioned that we can make use of a lock, so when a worker is modifying an entry, we lock that row to ensure that there are no race conditions. She did not seem satisfied with the answer and gave me an example. Lets say we want to update the status of a job. There is workerA that want to update the job to “failed” and B wants to update the same job to “done”, so when we use mutex, lets say worker A acquires the mutex first and update it to “failed” then B gets the mutex and updates it to “done”. So the task become done when its supposed to fail. To solve this problem, I said that we can check the status of the task is what we expected first before we change. To that, she asked me to write the SQL code to do so, which I told her I was not able to.

Lastly, she asked me some weird behavioural questions. She asked me what are my hobbies, and what are my strengths and weaknesses. hmmm…

At the end, I asked her how I did, and she said “ok la”, as a fresh grad, they do not expect us to get full marks for every question, and for every question, there are multiple ways of doing it.

Learnings:

  • Always prioritise runtime over space
  • Do the math properly, do not panic
  • Maybe I should have known bitmaps? Though I feel it was quite hard
  • Be more confident in my answers?

Remarks: got offered the role though, might have to do with me getting the dsta offer then emailing them saying they are my first choice lol, lucked out?