Skip to content
Related Articles

Related Articles

Fourkites Interview Experience | Summer Internship

View Discussion
Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 26 Apr, 2020
View Discussion
Improve Article
Save Article

This was a campus recruitment so the level and difficulty might vary according to your college

Round 1: Coding round on Hackerearth

Some 20 MCQ Questions on aptitude and C/Java code output and 2 Coding questions. I was able to pass all testcases for the first question whereas only 2/3 testcases for the second question. I was 1 of the 3 people selected from this round. I don’t remember the question as of now.

Round 2: Technical Round 1
We started by discussing my projects on resume and he asked me to elaborate on one of mine Node.js project which was a blogging site supported with Node.js + mongoose at the backend. I was asked why I used mongoose and not some relational database which was because I was learning at that time and the instructor was using mongoose so I went with the same. Then he asked me a question based on SQL

Question: Given a table, extract its odd columns.
I tried but since I didn’t the answer I accepted that I don’t know the answer
Then we continued with a programming question
Question 1: Given two linked lists how can you merge them into one sorted linked list.

My Solution:
I first merged the two linked list by joining the last node of the first linked list to the
first node of the second linked list and sorting them using bubble sort

He asked me to improve the complexity of the solution.
I asked him if there is any limit on memory, he said no. So I again joined them and
used counting sort on the merged list

Now he said assume there is a limit on memory.
I told him I know merge sort will be helpful to first sort them and then merge but
I don’t really know how merge sort is applied on linked lists, I know only for array and lists.
He asked the time complexity of merge sort and to assume its a sorted list now merge them. 
I used two pointers pointing to the start of the lists and merging their elements one by one by
moving the pointer one by one on the lower node until all the nodes aren’t added to the new list.
Here is the code

def merge(list1, list2):
    list1, list2 are the two sorted lists
    Function returns the merged list
    ptr1 = 0
    ptr2 = 0
    finalList = []
    # While any pointer reaches the end of the list
    while ptr1 < len(list1) and ptr2 < len(list2): 
        # If list2 has the smaller element add it and increase the pointer to the next position 
        if list1[ptr1]>list2[ptr2]:
            ptr2 += 1
        # Otherwise add element form list1 and increase the pointer to the next position
            ptr1 += 1
    # Adding the elements left in list1 or list2
    if ptr1 == len(list1):
        while ptr2 <l en(list2):
            ptr2 += 1
        while ptr1 < len(list1):
            ptr1 += 1
    # finalList contains the merged list
    return finalList

I was asked the time complexity of the program, I replied

O(min(n, m))

(Where n and m are the lengths of the lists). He corrected and told me its


Round 3: Technical Round 2
It started with a basic introduction and a question on data-structure.

Question: You have


logs and you can join two of them at a time with a cost
equal to the sum of their lengths. You have to join all the logs to a single log with minimum cost

My solution:
I took some time to think about the solution, I thought if I keep joining the two smallest ones
it should give the minimum cost so I asked for an example to better understand the problem.

5 logs of size 2 3 4 5 7. Answer: 47
2+3 = 5, logs = 4, 5, 5, 7 cost = 5
4+5 = 8, logs = 5, 7, 9 cost = 5+9
5+7 = 9, logs = 9, 12 cost = 5+9+12
9+12 = 21, logs = 21 cost = 5+9+12+21 = 47

I could have sorted the list but after each join, I will have to insert a new log into the list
that can take


for each log hence making the solution


So I used minheap to calculate the minimum logs every time. The top node is already the minimum
and after removing it the 2ed minimum comes to the root.
Insertion time in a heap is


which is a lot better than


Here is the code:

import heapq
def cost(n, logs):
    n is the number of logs
    logs is the list containing length of logs
    Returns the minimum cost of joining all the logs
    # Createing a min-heap using length of logs
    heap = []
    for i in range(n):
    cost = 0
    # Loop until one log is left
    while len(heap)>1:
        # Log with minimum value
        log1 = heap[0]
        # Removing the minimum / root value
        # Similarly second minimum log will be the minimum after the previous removal
        log2 = heap[0]
        # Length of new log which is equal to the cost of operation
        newlog = log1 + log2
        cost += newlog
        # Inserting the new log back in the heap
    # Cost stores the total cost for this operation
    return cost

I was asked the total time complexity of this operation which is


Round 4: Technical Round 3

The interviewee started off by asking me about my projects then asked why
Interviewee: Why do you want to do an internship in SDE
Me: I have loved problem-solving since I started competitive programming and I love doing development hence I find Software Development the right position for me.
Interviewee: What is your favorite Data Structure and
Me: Tree and then I brought up my project about generating test completion using Trie Data Structure and we discussed how we can handle large data when a lot of data with Trie. I suggested trimming the tree as most of the nodes at the leaf side will be NULL pointers which will help to save a lot on space in memory.
This was a pretty short interview that lasted for 30-40 minutes.

In the end, I was one of the 2 people selected as an SDE intern at Fourkites

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!