Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

Before you go!

Take this "Delhivery Interview Questions" interview guide with you

Welcome to Interviewbit, help us create the best experience for you!

Currently, You are a:

Few details about your education

College/University *
Enter the name of your college
Branch *
Year of completion *

Few details about your education

College/University *
Enter the name of your college
Branch *
Year of completion *

Few details about your career...

Current Company *
Enter company name *
Experience *

You're all set!

Begin your success journey!

Sign Up using
Full name *
Email *
Password *

By creating an account, I acknowledge that I have read and agree to InterviewBit’s Terms and Privacy Policy .

Welcome back!

Log In using
Email *
Password *

Delhivery Interview Questions

Begin your success journey!

Sign Up using
Full name *
Email *
Password *

By creating an account, I acknowledge that I have read and agree to InterviewBit’s Terms and Privacy Policy .

Welcome back!

Log In using
Email *
Password *

About Delhivery

Delhivery, which was founded in 2011 by Sahil Barua, Mohit Tandon, Bhavesh Manglani, Suraj Saharan, and Kapil Bharati, is one of the leading logistics companies based in India. Delhivery initially started with a food delivery service but soon they realized that e-commerce platforms also need logistic services. So they started with e-commerce logistics along with food delivery. At present, they provide a well-diversified supply chain solution to their customers and their client base is 23,000+. 

Delhivery provides a very good work culture, therefore, employees love to work here. Due to flexible working hours, you will get a good work-life balance along with a comfortable environment. Employees at Delhivery get to work on the latest tech stack such as amazon web services(AWS),  spinnaker, service mesh(istio), k8s, etc which results in exponential self-growth.

As a software developer at Delhivery, your key responsibilities include:

  • Work closely with the quality assurance and product teams to manage the development of specific products within the organization by providing technical recommendations and developing systems that are scalable, sound, maintainable, risk-tolerant, and can work on any platform i.e platform independence should be there.
  • Converting product requirements into scalable apps that are deployable on cross-platform
  • Managing your code from concept to implementation by leveraging the 12-factor app methodology
  • Being an integral part of the company's management team responsible for setting the company's strategies
  • Providing the use of the most optimal resources for the product development

This article will cover a variety of questions around different topics such as its recruitments, tips, faqs and more which will help you in giving an edge over other candidates so that you can easily crack a Delhivery inteview.

Delhivery Recruitment Process

Interview Process

Before giving an interview for a company, you should be familiar with its interview process. So, let’s look at how Delhivery hires its employees.

The recruitment process at Delhivery generally consists of 4 rounds. In these rounds, you will be judged on the basis of your cognitive as well as technical skills. The 4 rounds are

  1. Coding Round
  2. Technical interview 1
  3. Technical interview 2
  4. HR Round

Interview Rounds

The Delhivery recruitment process generally consists of 3 to 4 rounds depending upon whether you are applying on-campus or off-campus or whether you are experienced or fresher.

Round 1: Coding Round

This round is conducted on the HackerEarth platform and in this round, you will get MCQ questions as well as coding questions. You will be given 3 coding questions of medium difficulty level and the number of MCQ questions can vary. MCQs can be around a variety of topics that you have studied in your preparation journey like computer networks, OOPS, DBMS, SQL query, operating system, system security, data structures like trees, LinkedList, etc.

Round 2: Technical Interview 1

The interview round will start with your introduction. The recruiter can also ask about your projects and internships. After that, you will be asked a number of programming questions. The questions can be based on your projects, data structures, algorithms,  etc. If you want to know more about these questions you can check out the article further where we have discussed the most commonly asked Delhivery interview questions.

Round 3: Technical Interview 2

  • In this round, the recruiter can scan your resume and ask questions based on it. The questions can be about the projects that you have mentioned in your resume. If your project was based on react and javascript then he will ask you questions based on that.
  • If you are applying for an experienced role then design-based questions can also be asked.
  • Freshers and experienced, both can be asked to design a database and perform queries on that.

Round 4: HR Round

As part of this round, you will be asked general questions such as:

  • Why do you want to work in Delhivery
  • What do you know about our company
  • What are your strengths and weaknesses
  • Your previous experiences in the technical field.

Delhivery Technical Interview Questions: Freshers and Experienced

1. Explain the OSI model?

  • OSI model which stands for open system interconnection model was proposed in 1983 to provide different functionalities for communication between networks.
  • It was developed by the International Standards Organization (ISO) and it contains 7 layers, unlike the TCP/IP model which was proposed earlier and contains 5 layers.
  • The seven layers of the OSI model are the Physical layer, Data Link layer, Network layer, Transport layer, Session layer, Presentation layer, and Application layer. All these layers provide different functionalities for communication in a network. All the layers of the OSI model are linked to each other.

The functionalities of different layers of the OSI model are

  • Physical Layer: Physical layer of the OSI model is the lowest layer among all and is responsible mainly for the physical connection between networks. The data is sent in the form of bits i.e. 0 and 1. Dealing with cables, repeaters, etc comes under the functionality of the physical layer.
  • Data Link Layer: Data link layer is mainly responsible for converting the data into frames and transferring it from one node to another The data link layer is further divided into two layers namely MAC which stands for media access control and another one is LLC which stands for logic link control.
  • Network Layer: The network layer provides the functionality of receiving the data in the form of frames from the data link layer and determining the route for sending the data to the destination using the logical addresses. It helps in selecting the optimal path from the source to the destination for the transfer of data.
  • Transport Layer: Protocols such as TCP i.e transmission control protocols are present in this layer. The transport layer is responsible for delivering error-free data to the destination address. Acknowledgement of data that is sent through the network is essential and the transport layer takes care of that. If the acknowledgement is not received then the transport layer helps in retransmitting the data.
  • Session Layer: The session layer is the 5th layer of the OSI model and functionalities such as providing security during the transmission of data in a network to keep our data safe, authentication, synchronization establishment, and termination of connections are provided by the session layer of OSI model.
  • Presentation Layer: The presentation layer checks the data for syntax and semantics before sending it to the application layer. Other functionalities of the presentation layer include encrypting and describing the data and also reducing the size of data while transferring which is known as compression.
  • Application Layer: Among the 7 layers of the OSI model, the application layer stands at the top. This layer is responsible for the interaction of the end-user with the application. This layer mainly helps in communicating with other devices. FTP, SMTP, and HTTP are the important protocols that are present in this layer.

2. What is paging in memory management?

  • Paging is a non-continuous allocation method in which a process is divided into equal parts called pages so that they can be brought to the main memory in the form of pages.
  • The main memory is also divided into frames and the size of frames is always equal to the size of the page so that a page can be easily accommodated in a frame.
  • The pages reside in the secondary memory and are brought to the main memory only when required.

3. Write a program for calculating the Stock Span

Problem Discussion:

You are given an array arr containing prices of the stock on different days. Your task is to calculate span i.e the number of days before the current day during which the price of the stock was equal to or less than the price at which the stock is trading on a given day.

The figure below shows the span of stocks on different days.

Algorithm:

  • We will be using a stack for storing the index
  • Create a span array and put 1 at the 0th index because the span for the first element will be 1.
  • Create a stack and push the first index i.e. 0.
  • Start traversing from the first index of the array and for each element:
  • If the value of the current element is greater than the top element present in the stack then pop all the elements of the stack until the stack is empty or the value of the current element becomes less than the top element of the stack
  • Now check whether the stack is empty or not.
  • If the stack is empty that means that the current stock price is highest until now therefore store index+1 in the span array else store the difference between the current index and the top of the stack.

Implementation:

#include<stdbool.h>
#include<iostream>
using namespace std;
#include<string>

class node{
public:
 int data;
 class node* next;

 node()
 {
     data=0;
      next=NULL;
 }
}*top=NULL;

class Stack{

    public:

void push(int x){
       node *p=new node;
    if(top==NULL){

     p->data=x;
     p->next=NULL;
     top=p;}
     else{

     p->data=x;
     p->next=top;
     top=p;
     }
 }

 int pop(){
    int ch;
    ch=top->data;
    top=top->next;
    return ch;
 }

 bool isempty(){
 if(top==NULL){
 return true;}
 else{
    return false;
 }
 }

};

void stkspan(int arr[],int n){
    Stack st;
    int arr1[n];
    arr1[0]=1;
    st.push(0);
    for(int i=1;i<n;i++){

            while(st.isempty()==false && arr[i]>=arr[top->data])
            {
                st.pop();
            }
            if(st.isempty()==true)
            {
                arr1[i]=i+1;
            }
            else{
            arr1[i]=i-top->data;
            }
             st.push(i);

    }
    for(int j=0;j<n;j++)
    {
        cout<<arr1[j]<<endl;
    }
}

int main()
{
    int n;

cin>>n;
int *arr=new int[n];

for(int i=0;i<n;i++){
    cin>>arr[i];
}
stkspan(arr,n);
}

Time and Space analysis:

  • Time Complexity: O(N), where n is the number of elements in the array.
  • Space Complexity: O(N), where n is the number of elements in the array.

4. State some of the uses of normalization?

  • When we are dealing with a large amount of data the chances of redundancy increase therefore normalization helps in decreasing redundancy.
  • In order to decrease complexity, normalization looks at the new data types added to the table.
  • A big database table can be broken up into smaller tables and linked with relationships.
  • Anomalies are less likely to appear in a database with the help of normalization.

5. Write a program to calculate the power of a number.

Algorithm:

  • The approach is simple. We will use the divide and conquer method i.e we will divide a larger problem into subproblems recursively for calculation of the power of a number.
  • In the base case return 1 since the power of any number to the power 0 is 1.
  • We will store the recursive function in a temporary variable instead of calling the function 2 times to optimize the solution from O(N) to log(N).

Implementation:

#include<iostream>
using namespace std;
class Interviewbit
{
      
public:
int pow_function(int a, unsigned int b)
{  int x;
    if (b == 0){
        return 1;
    }
     x=pow_function(a, b / 2);
     if (b % 2 == 0){
        return x * x;}
    else{
        return a * x * x;
    }
}
};
  
int main()
{
    Interviewbit i;
    int a = 4;
    unsigned int b = 6;
  
    cout << i.pow_function(a, b);

}

Time and Space analysis:

  • Time Complexity: O(log n) 
  • Auxiliary Space: O(1)

6. Draw the process state diagram of the OS.

7. Write a program to create and insert a new node in a binary tree in a level order manner

The figure shows how you can insert a node in a level order manner.

Algorithm:

  • For traversing in a level order manner, a queue is required because a queue follows FIFO i.e. first in first out.
  • For inserting a node, first, check whether the root node is not or not. In the base case. If the root is NULL, then create a new node and return it.
  • Now traverse the tree in a level order manner using a queue and find the first empty space for inserting the new node.
  • If the left child of the node is NULL then insert the new node to the left, else check for the right child.
  • If the left or right child is not NULL, then insert their children into the queue and traverse until the queue becomes empty.

Implementation:

#include <iostream>
#include <queue>
using namespace std;

struct Node {
    int val;
    Node* lval;
    Node* rval;
};
 
//Function to create a new node
Node* newNode(int val)
{
    Node* n = new Node();
    if (!n) {
        cout << "Memory error\n";
        return NULL;
    }
    n->val = val;
    n->lval = n->rval = NULL;
    return n;
}
 
//Function to insert the given node
Node* Insert(Node* root, int val)
{

    if (root == NULL) {
        root = newNode(val);
        return root;
    }
 
    queue<Node*> que;
    que.push(root);
 
    while (!que.empty()) {
        Node* x = que.front();
        que.pop();
 
        if (x->lval != NULL)
            que.push(x->lval);
        else {
            x->lval = newNode(val);
            return root;
        }
 
        if (x->rval != NULL)
            que.push(x->rval);
        else {
            x->rval = newNode(val);
            return root;
        }
    }
}
 //Inorder traversal of a BT
void inorder(Node* x)
{
    if (x == NULL)
        return;
 
    inorder(x->lval);
    cout << x->val << ' ';
    inorder(x->rval);
}

int main()
{
    Node* root = newNode(5);
    root->lval = newNode(1);
    root->lval->lval = newNode(7);
    root->rval = newNode(9);
    root->rval->lval = newNode(16);
    root->rval->rval = newNode(10);
 
    cout << " Before insertion: ";
    inorder(root);
    cout << endl;
    int add = 11;
    root = Insert(root, add);
 
    cout << "After insertion: ";
    inorder(root);
    cout << endl;
 
    return 0;
}

Time and space analysis:

  • Time Complexity: O(N), where N is the number of nodes in the given binary tree
  • Space Complexity: O(1)

8. How do processes and programs differ?

A program is a set of instructions to be performed that resides in the secondary memory but when a program is executed it gets converted to a process which is then loaded to the main memory.

9. Write a program to reverse a string with the help of stack

Algorithm:

  • Create a string p of size n.
  • Create a stack of size n to store all the char of the string
  • Traverse the string using a loop from the left and push each and every character in the stack
  • When you come out of the loop, create a loop again to pop the elements from the stack and store them in a string.
  • Since stack follows LIFO i.e. last in first out, the popped string will be reversed.
  • Return the reversed string and print it.

Implementation:

#include <bits/stdc++.h> 
using namespace std; 
  
class Stack{  
    public: 
        int top;  
       int size;  
        char* array;  
};  
  
Stack* Stack_create(unsigned size){
    
    Stack* new_stk = new Stack(); 
    new_stk->size= size;  
    new_stk->top = -1;  
    new_stk->array = new char[(new_stk->size * sizeof(char))];  
    return new_stk;  
}  
  
int stackfull(Stack* stk){ 
    return stk->top == stk->size - 1; 
}  
  
int stackempty(Stack* stk){ 
    return stk->top == -1; 
}  
  
void push(Stack* stack, char item){  
    if (stackfull(stack))  
        return;  
    stack->array[++stack->top] = item;  
}  
  
char pop(Stack* stk){
    if (stackempty(stk))  
        return -1;  
    return stk->array[stk->top--];  
}  
  
void string_reverse(char p[]){  
    int n = strlen(p);  
    Stack* stk = Stack_create(n);  
  
    int i;  
    for(i = 0; i < n; i++){  
        push(stk, p[i]); 
    }    
  
    for(i = 0; i < n; i++){  
        p[i] = pop(stk);
    }    
}  
  
int main(){  
    char p[] = "Welcome_To_InterviewBit";  
  
    string_reverse(p);  
    cout<<p<<endl;  
  
}

Time and space analysis:

  • Time Complexity: O(N)
  • Auxiliary Space: O(N)

10. You are given 8 matchsticks out of which 4 are of the same length having length x while the other 4 are of the same length having length y. Given y=x/2, can you form 3 squares of the same size using these sticks?

You can follow the steps mentioned below to form 3 squares of equal sizes:

1. Initially, place the first matchstick having length x  in the horizontal direction

2. In the next step place the second matchstick having length x in the vertical direction such that they form a cross.

3. In step 3, place the 3rd matchstick of length x below the vertical matchstick in a horizontal direction as shown in the figure.

4. Now place the last matchstick of length x in the vertical direction such that it forms a square and divides the last-placed matchstick into 2 halves.

5. Now start placing the matchstick of length y in a horizontal direction at the last level.

6. Complete another square by placing the matchstick in a vertical direction.

7. Place another matchstick in the horizontal direction at the top level.

8. Finally, complete the structure by forming three squares of equal size by placing the last matchstick of length y in the vertical direction.

11. Find maximum distance between occurrences

Problem Discussion:

You will be given an array arr. Your task is to find the maximum distance between the two same elements in the array. 

For eg:

Input array arr=[3, 4, 6, 7, 4, 8, 9, 3]

The output will be 7 because the maximum distance is between the first element and the last element of the array.

Note: The given array arr will always contain repeated elements.

Algorithm:

  • A brute force approach is to use nested for loops and calculate the maximum distance between two occurrences for each and every elements but it would take O(n2) time.
  • An optimized approach that would take O(n) can be implemented using a map.
  • First of all, declare a map for storing the first occurrence of each element.
  • Using a loop, traverse every element and check whether the element is already present in the map or not.
  • If the element is already present then update the maximum distance between two occurrences and if it is not found then store the index of the current element in the map.
  • At last return the maximum distance

Implementation:

#include<bits/stdc++.h>
using namespace std;
 
int disBetweenOccurence(int arr[], int n)
{
    unordered_map<int, int> interviewbit_mp;
 
    int dist_betweeen_occurences = 0;
    for (int i=0; i<n; i++)
    {

        if (interviewbit_mp.find(arr[i]) == interviewbit_mp.end())
        {
            interviewbit_mp[arr[i]] = i;
        }
        else{
    dist_betweeen_occurences = max(dist_betweeen_occurences, i - interviewbit_mp[arr[i]]);
            
        }
    }
    return dist_betweeen_occurences;
}
 
int main()
{
    int arr[] = {3, 4, 6, 7, 4, 8, 9, 3};
    int n = sizeof(arr)/sizeof(arr[0]);
    cout << disBetweenOccurence(arr, n);
    return 0;
}

Time and space analysis: 

  • Time complexity:O(N), where n is the number of elements in the array.
  • Space Complexity: O(N), where n is the number of elements in the array.

12. In what condition does the worst case of QuickSort occur?

  • The worst case of the quick sort occurs when the array is sorted, resulting in time complexity of O(N2).
  • We use the partitioning method in quick sort in which we select a pivot and find the correct position for that pivot element. The elements smaller than the pivot element are on one side and the greater elements are on the other side.
  • If the array is sorted then partitioning happens at the end of the array resulting in time complexity of O(N2).

13. What is the basic difference between function overloading and function overriding?

  • Function overloading means 2 functions that are declared with the same name but have any one of the following parameters different among them:
    • The number of arguments passed to the function can be different
    • The type of arguments passed can be different
    • The ordering of arguments in the function can be different
  • Function overriding is similar to overloading but in overriding both the functions are in different class i.e. base class and derived class whereas in overloading both functions are in the same class. Overriding is applied in the situations where a function is defined in the base class but more functionalities are defined in the derived class.

14. Rotate a matrix by 90 degrees in a clockwise manner.

Problem Discussion:

Suppose you are given a matrix:

mat[n][n] = { {1, 2, 3}, { 7,8,9  }, {  10, 11, 12 }, };

Your task is to rotate this matrix by 90 degrees in a clockwise manner.

So the output will look like this:

10 7 1 
11 8 2 
12 9 3 

Algorithm:

To rotate the matrix by 90 degrees you just have to follow 2 steps:

  • Take transpose of the matrix
  • Reverse all the rows of the matrix

1  2  3                                                        1  7  10                                                            10  7   1

7  8  9             ——Transpose——>      2  8   11         —-Reverse  rows—->          11  8  2  

10  11  12                                                 3   9  12                                                           12  9  3

Implementation:

#include <iostream>
using namespace std;
const int n = 3;
void print(int given_matrix[n][n])
{
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++)
            cout << given_matrix[i][j] << " ";
        cout << endl;
    }
}
void rotate_a_matrix_by_90_degrees(int given_matrix[n][n])
{

    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            swap(given_matrix[i][j], given_matrix[j][i]);
  
    for (int i = 0; i < n; i++) {
        int left = 0, right = n - 1;
        while (left < right) {
            swap(given_matrix[i][left], given_matrix[i][right]);
            left++;
            right--;
        }
    }
}
int main()
{
    int given_matrix[n][n]
        = { {1, 2, 3},
                      { 7,8,9  },
                      {  10, 11, 12 },
                      };
    rotate_a_matrix_by_90_degrees(given_matrix);
    print(given_matrix);
}

Time and space Analysis:

  • Time Complexity – O(N2)
  • Auxiliary Space – O(1)

15. What is amortized time complexity?

  • Amortized time complexity analysis is used in data structures where the frequency of high-cost operations is low compared to low-cost operations.
  • Let’s understand it through an example:
  • Suppose you have to insert elements in a dynamic array whose initial size is 1. So for 1 insertion, there is no problem but for 2nd insertion, we actually have to double the size of the array.
  • In memory, the array size does not double but creates a new array of double size and copies all the elements from the previous array. After copying the previous elements, a new element is inserted. This will take 3*(size of array+1) operations. So for inserting n elements the time complexity will be N* 3N i.e O(N2).

Now, let’s do an amortized time complexity analysis:

  • So this whole process will take 2(for doubling the size)+2(for copying the elements)+1(for inserting new element) operations.
  • Again for inserting the next element we have to double the size of the array which will take 4+2+1operations.
  • Now the 4th element can be inserted in just 1 operation.
  • Again for the 5th element, the size of the array will be doubled and 8+4+1 operations will be performed, and so on.
  • Hence, the number of operations is either 1 or 3*size of array +1.
  • The 3*(size of array+1) operation will occur when the array size is 1 then 2 then 4 then ……2N.
  • It will form a G.P of the form:

           3(1+2+4…………+2N).

  • After solving this expression you will get 12N will equal to O(N).

As you can observe by using amortized analysis, we reduced the time complexity from the worst case, O (N2) to O(N), just by doing a better analysis. So amortized analysis says that instead of looking at the worst case we should do a better analysis of the algorithm.

16. Find 2 missing numbers

Problem Discussion:

This is a follow up question of finding missing elements. If you successfully tell the approach for finding missing elements to the interviewer then you will surely get this follow up question. In the previous question, you were required to find a single missing element but in this question, you have to find 2 missing elements in the range 0 to n.

Algorithm:

  • This question can be solved using xor operations efficiently.
  • First of all take the xor of all the elements present in the array with natural numbers from 1 to n. For eg: If the given array is [1,2,4,6] then xor these with natural numbers from 1 to 6. This will give us 3^5. But the problem is we don’t know which are the exact numbers that are missing, we just know the xor of those numbers.
  • So to solve this problem we will consider the rightmost set bit in xor of 3 and 5. The rightmost bit can be calculated using the formula XOR & ~(XOR-1).
  • In xor operation a set bit is formed by combination of 0 and 1. Therefore if we perform xor operation of all the elements in the array which have their rightmost set bit as 1 with all the natural numbers in the range then we will get the first missing number. Similarly, if we perform xor operation of all the elements in the array which do not  have their rightmost set bit as 1 with all the natural numbers in the range then we will get another missing number.

Implementation:

#include<bits/stdc++.h>
  
void function_for_missing(int nums[], int n)
{
 
    int XOR = nums[0];
    for (int i = 1; i < n-2; i++)
        XOR ^= nums[i];
    for (int i = 1; i <= n; i++)
        XOR ^= i;
 
    int set_bit_no = XOR & ~(XOR-1);

    int a = 0, b = 0; 
    for (int i = 0; i < n-2; i++)
    {
        if (nums[i] & set_bit_no)
            a = a ^ nums[i]; 
        else
            b = b ^ nums[i]; 
    }
    for (int i = 1; i <= n; i++)
    {
        if (i & set_bit_no)
            a = a ^ i; 
        else
            b = b ^ i; 
    }
  
    printf("The numbers which are not present are\n %d %d", a, b);
}
  
int main()
{
    int nums[] = {1, 3, 5, 6};
  
    int n = 2 + sizeof(nums)/sizeof(nums[0]);
  
    function_for_missing(nums, n);
  
    return 0;
}

Time and Space analysis:

Time Complexity : O(n) 

Auxiliary Space : O(1)

17. Min distance between 2 distinct numbers

Problem Discussion:

You are given an array arr and two numbers a and b. Your task is to find the minimum gap between the numbers a and b.

Note:

  • The array given will be unsorted and it may contain duplicates.
  • Both a and b are different and surely present in the given array arr.

For eg:

arr[] = {4, 5, 4, 2, 1, 4, 0, 0, 5, 4, 8, 4}, a=b and b=1

The minimum gap will be 1.

Algorithm:

  • A brute force approach would be to use nested loops which would take O(N2) time.
  • This problem can also be solved using a single loop.
  • Traverse the array and maintain a variable min_gap.
  • If the element is equal to a or b update the min gap else just updates the position of p i.e the previous element.
  • If min_gap==INT_MAX, in that case, return -1 which means the minimum gap is not found

Implementation:

#include <bits/stdc++.h>
using namespace std;
 
int findminimumgap(int arr[], int n, int a, int b)
{

    int p = -1, min_gap = INT_MAX;
     
    for(int i=0 ; i<n ; i++)
    {
        if(arr[i]==a|| arr[i]==b)
        {
         
            if( p != -1 && arr[i] != arr[p])
                min_gap = min(min_gap , i-p);
              
         
            p=i;
        }
    }

    if(min_gap==INT_MAX)
        return -1;
 
    return min_gap;
}
 

int main()
{
    int arr[] = {4, 5, 4, 2, 1, 4, 0, 0, 5, 4, 8, 4};
    int n = sizeof(arr) / sizeof(arr[0]);
    int a = 4;
    int b = 1;
 
    cout << "Minimum distance is -> "<<
                        findminimumgap(arr, n, a, b) << endl;
    return 0;
}

Time and space analysis:

  • Time Complexity: O(N2), where N is the number of elements in the array
  • Space Complexity: O(1)

18. Is it possible to overload the main method in Java?

  • You might think that overloading the main method is not possible but in reality, the main method can be overloaded in Java.
  • Even if we overload the main method, Java virtual machine will still call the original main method, not the one overloaded by us.

19. Compare the different version numbers

Problem Discussion:

You are given version numbers and these are of the form w.x.y.z where x,y, z and w are strings which are separated by a dot. Your task is to compare two given strings/version numbers and return the version number which is smaller. Suppose you are given two versions 2.0 and 2.1 then 2.0 will be considered smaller.

For eg:

s1=7.0.1.23

s2=7.0.1.17

The output will be 7.0.1.17 because s2 is smaller

Algorithm:

  • The given string or versions contain dots therefore we have to trace them part by part.
  • Traverse the versions and compare the strings between dots.
  • For comparing the string first compare them into integer
  • Maintain two variables version1 and version2 for calculating the value between dots.
  • If both the numbers between dots are equal make version1 and version2 zero and traverse again else return the version which is smaller.

Implementation:

#include <bits/stdc++.h>
using namespace std;
 
int check(string s1, string s2)
{
    int version1 = 0, version2 = 0;

    for (int i = 0, j = 0; (i < s1.length()
                            || j < s2.length());) {
   
        while (i < s1.length() && s1[i] != '.') {
            version1 = version1 * 10 + (s1[i] - '0');
            i++;
        }
 
        while (j < s2.length() && s2[j] != '.') {
            version2 = version2 * 10 + (s2[j] - '0');
            j++;
        }
        if (version1> version2)
            return 1;
        if (version2 > version1)
            return -1;

        version1 = version2= 0;
        i++;
        j++;
    }
    return 0;
}
 
int main()
{
    string s1 = "0.5.3";
    string s2 = "0.5.7";
 
    if (check(s1, s2) < 0)
        cout << s1 << " is smaller\n";
    else if (check(s1, s2) > 0)
        cout << s2 << " is smaller\n";
    else
        cout << "Both version are equal\n";
   
}

Time and space analysis:

  • Time Complexity: O(n), where n is the length of the string. 
  • Auxiliary space: O(1)

20. Find the missing number.

Problem Discussion:

You are given an unsorted array of size n in which 1 element is missing in the range of 0 to n. Your task is to find that number.

For eg:

Suppose the given array is [3,0,1].

The output will be 2 since the size of the array is 3.

Algorithm:

  • The missing number can be found easily using the xor operation in just O(N) time.
  • Keep in mind the following properties of xor before coding the solution:
    • Xor of two different numbers is 1.
    • Xor of the number with itself is 0.
    • Xor of a number with 0 is the number itself.
  • So for finding the missing number do xor of all the numbers between 1 to n and then xor those numbers with all the numbers present in the array.
  • After performing these operations you will finally get the missing element.

Implementation:

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n-1];
  for(int loop=0;loop<n-1;loop++)
  {
      cin>>a[loop];
  }
  int xor1 = 0,xor2 = 0;
  for(int i=1;i<=n;i++)
  {
      xor1^=i;
  }
  for(int i=0;i<n-1;i++)
  {
      xor2^=a[i]; 
  }
  int ans=xor1^xor2;
  cout<<"The number not present between 0-n is: "<<ans<<endl;
  return 0;
}

Time and space analysis:

  • Time Complexity: O(N)
  • Space Complexity: O(1)

Useful Resources

Delhivery Interview Preparation

Interview Preparation Tips

  • Practice questions daily: The coding questions which you will get will not be of easy level so you should have a good practice with a variety of problems. You can practice on platforms such as InterviewBit, CodeChef, codeforces, leetcode, etc.
  • Core subjects: You will be asked questions based on core subjects such as OOPS, DBMS, and computer networks in your interviews therefore you should have a good command of these topics.
  • Practice puzzles: Practice a variety of questions on puzzles because these can be asked in your interview at delhivery. You can practice questions on puzzles on our website also through this link. These questions are specially prepared for interview purposes for helping the candidates get their dream jobs.
  • Resume Projects: Have a decent number of projects in your resume like 2 to 3 projects which you can discuss with the interviewer.
  • Communication: Apart from having knowledge of all topics, good communication skills are equally important. You should be able to explain your approach properly to the recruiters. To improve your communication skills you can give mock interviews 2 to 3 weeks before the actual interview.

Delhivery Coding Questions

Best Time to Buy and Sell Stock atmost B times
Dynamic Programming
Solve Problem
K Largest Elements
Heaps And Maps
Solve Problem

Frequently Asked Questions

1. Why do you want to work at Delhivery?

  • Delivery is a  very good company to work for. The company has been growing exponentially for the past 5 years and delhivery always gives credit for its success to its employees.
  • Delhivery has a very good work-life balance and you will get to learn a lot while working for delhivery. The colleagues are very helpful and the HR team is also very supportive whenever you face any difficulty.
  • In terms of compensation, Delhivery pays a good amount for candidates with extraordinary skills.

2. What is the salary for freshers in Delhivery?

Delhivery software developer salaries are very good. Delhivery pays its freshers an average salary of 8-10.1 lakhs per year for the Developer role. Delhivery's leading position is that of Senior Director, which comes with pay of ₹41.2 Lakhs per year. Those in the top one per cent earn more than ₹29.9 lakhs each year.

3. How long is the Interview Process at Delhivery?

The interview process starts with a coding test on the HackerEarth platform which is generally 90 min. If you qualify for that test, one week later you will have your interview scheduled which is of 60-90 min duration each. So it takes approximately 1-2 weeks for the interview process to complete.

4. What is the Eligibility Criteria at Delhivery?

To apply for the role of software engineer at Delhivery, here are the required eligibility criteria:

  • Educational Qualification: BE/B.Tech (with any specialization)
  • GPA of 6.5 or more throughout with no running backlog
  • Good Programming Skills.
  • Good Analytical Skills.
  • Good Communication Skills.
Get Placed at Top Product Companies with Scaler Know More 
Get Placed at Top Product Companies with Scaler Know More 
Get Placed at Top Product Companies with Scaler
Sat transparent 640a34d454880bf68e3bfdf33f2389f2214043f59ad18b4c7f7b114e834fb257.svg

Point markers b3add1cc88e4996b2df6e0aedb9f0d1b65fa73c51b7ada8fbee3895a2aa11802.svg Personalised feedback report with solutions
Point markers b3add1cc88e4996b2df6e0aedb9f0d1b65fa73c51b7ada8fbee3895a2aa11802.svg Real life Interview Questions
Point markers b3add1cc88e4996b2df6e0aedb9f0d1b65fa73c51b7ada8fbee3895a2aa11802.svg Identify exact topics to improve

Your feedback is important to help us improve.
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Graduation Year *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+91 *
+91
Change Number
Phone Number *
OTP will be sent to this number for verification
+91 *
+91
Change Number
Graduation Year *
Graduation Year *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test