Flipkart Coding Questions and Answers

Sample Flipkart Coding Questions with Solution

Here, on Flipkart coding questions and answers page you will get sample DSA questions with solution which can be asked in Flipkart SDE 1 Coding Assessment.

Let you know that Flipkart mainly asks Data Structures and Algorithms based questions based Binary Search Tree, Graphs, Tries, Trees and Dynamic programming.

Checkout this page get all the Sample Flipkart Coding Questions with Solutions.

About Round 1 – Flipkart Coding Assessment

First stage of the Flipkart SDE-1 recruitment process is an online coding assessment, conducted on HackerRank

This round serves as an initial screening to evaluate your problem solving and coding skills.

  • Duration: 90 minutes

  • Platform: HackerRank

  • Number of Questions: 3 coding problems

  • Difficulty Level: Medium to Hard

  • Topics Covered:

    1. Binary Search Trees (BST)

    2. Tries (Prefix Trees)

    3. Tree and Graph Traversals (DFS, BFS)

    4. Graph Algorithms (Cycle detection, shortest paths, connected components)

    5. Dynamic Programming (Tabulation, memoization, optimization problems)

To succeed in this round, focus on writing clean, optimized code and thoroughly testing your solutions against edge cases.

After this round 2 Technical Interviews followed by Hiring Manager Round  will be conducted for assessing the candidates.

Practice Coding Questions:

Checkout PrepInsta Prime:

Flipkart Coding Questions with Solutions

1. Program for Finding Minimum in a Rotated Sorted Array Problem

You are given a sorted array that has been rotated between 1 and n times. For example:

  • If the array [1,2,3,4,5,6] is rotated 4 times, it becomes [3,4,5,6,1,2].
  • If rotated 6 times, it goes back to [1,2,3,4,5,6].

Your task is to find the smallest element in this rotated array. The elements in the array are unique.

While finding the minimum in O(n) time is easy, you need to write an algorithm that works in O(logn) time.

Constraints:

  • 1 <= nums.length <= 1000
  • -1000 <= nums[i] <= 1000

Solution with Binary Search Method

Use binary search to narrow down the search space by checking if the middle element lies in the rotated part, giving an O(logn) solution.

  • Time complexity: O(log 1)
  • Space complexity: O(1)

Code

2. Design Add and Search Words Data Structure

Design a data structure to store words and efficiently support word addition and searching, including flexible matching.

Implement the WordDictionary class with the following methods:

  • addWord(word): Adds the given word to the data structure, allowing it to be stored for future searches. This is useful for building a collection of words dynamically.
  • search(word): Searches for a word in the data structure. The search supports both exact matches and partial matches using the . character as a wildcard. The . can represent any letter, making the search versatile for patterns or incomplete words.

This structure is particularly useful for applications like pattern matching or word suggestions.

Explanation:

  • WordDictionary wordDictionary = new WordDictionary();
  • wordDictionary.addWord(“day”);
  • wordDictionary.addWord(“bay”);
  • wordDictionary.addWord(“may”);
  • wordDictionary.search(“say”); // return false
  • wordDictionary.search(“day”); // return true
  • wordDictionary.search(“.ay”); // return true
  • wordDictionary.search(“b..”); // return true

Constraints:

  • 1 <= word.length <= 20
  • word in addWord consists of lowercase English letters.
  • word in search consist of ‘.’ or lowercase English letters.

Solving with Brute Force Method

Words are stored in a list, and each search checks all words by iterating through them, including handling wildcards (.) character by character. This leads to a time complexity of O(m * n), where m is the number of words and n is the word length.

  • Time complexity: O(n) for addWord(), O(m∗n) for search().
  • Space complexity: O(m*n)

where m is the number of words added and n is the length of the string.

Code

Flipkart Coding Questions with Solutions

3. Maximum Depth of Binary Tree

You are given the root of a binary tree, and your task is to determine its depth.

Depth of a binary tree refers to the number of nodes present along the longest path starting from the root node down to the farthest leaf node. 

In simpler terms, it measures how deep the tree goes from the topmost node (the root) to the bottommost node (a leaf with no children). This depth represents the maximum number of steps needed to traverse the tree vertically.

Example:

Graph of Maximum Depth Array

Constraints:

  • 0 <= The number of nodes in the tree <= 100.
  • -100 <= Node.val <= 100

Solving with Iterative DFS(Stack) Method

This method uses a stack to simulate the depth-first traversal iteratively. Each node is paired with its depth and pushed onto the stack. As you process each node, you update the maximum depth by comparing the current depth of the node with the recorded value.

  • Time complexity: O(n)
  • Space complexity: O(n)

Code

4. Number of Connected Components In An Undirected Graph Problem

 Given an undirected graph with n nodes, an edges array is provided where edges[i] = [a, b] indicates an edge between node a and node b.

The nodes are numbered from 0 to n – 1. The task is to return the total number of connected components in the graph.

Constraints:

  • 1 <= n <= 100
  • 0 <= edges.length <= n * (n – 1) / 2

Solving with Disjoint Set Union (Rank | Size) method

DSU tracks the connected components using a union-find approach, where nodes are grouped into sets. Using union by rank or size ensures efficient merging of components, and the number of connected components is determined by the number of distinct sets.

  • Time complexity: O(V+(E∗α(V)))
  • Space complexity: O(V)

Where V is the number of vertices and E is the number of edges.

Code:

Flipkart Coding Questions

5. Maximum Product Subarray Problem

Given an integer array nums, find the subarray with the maximum product and return its value.

A sub array is a continuous, non-empty portion of the array.

You can assume the result will fit within a 32-bit integer.

Constraints:

  • 1 <= nums.length <= 1000
  • -10 <= nums[i] <= 10

Solving with Kadane’s Algorithm method

Modify Kadane’s algorithm to handle products by keeping track of both the maximum and minimum products at each index. This efficiently handles both positive and negative numbers.

  • Time complexity: O(n)
  • Space complexity: O(1)

Code

6. Merging Triplets to Form a Target Triplet

The Merge Triplets to Form Target problem involves determining whether you can construct a specific triplet using a series of merging operations on given triplets.

Problem Description

Input

  1. triplets: A 2D list where each triplet is of the form [a, b, c].
  2. target: A triplet [x, y, z] that we aim to construct.

Operation

For two triplets triplets[i] = [ai, bi, ci] and triplets[j] = [aj, bj, cj], you can update triplets[j] as follows:
 triplets[j]=[max(ai,aj),max(bi,bj),max(ci,cj)]

Goal

Determine whether it is possible to make target an element of triplets after performing the allowed operations.

Constraints:

  • 1 <= triplets.length <= 1000
  • 1 <= ai, bi, ci, x, y, z <= 100

There are mainly two  approach to solve this problem – 

  1. Greedy
  2. Greedy (Optimal)

Flipkart Coding Questions and Answers

1. Greedy

  • Time complexity: O(n)
  • Space complexity: O(1)

2. Greedy (Optimal)

Time & Space Complexity
  • Time complexity: O(
  • Space complexity: O(1)

If you want to practice more for Flipkart Coding Assessment, you can visit our Coding Blogs that will surely help you to prepare for Flipkart SDE 1 Coding Assessment and Flipkart Technical Interviews. 

Practice Coding Questions:

Checkout PrepInsta Prime:

Faq's Related to Flipkart Coding Assessment

Answer:

The coding questions typically range from medium to hard difficulty, covering data structures, algorithms, and problem-solving logic relevant to real-world scenarios.

 

Answer:

Yes, Flipkart often includes problems based on Trees, Graphs, Binary Search Trees (BST), and Tries, so it’s important to have a solid grasp of these topics.

 

Answer:

Yes, HackerRank allows you to code in your preferred programming language, though proficiency in C++, Java, or Python is recommended due to better support and familiarity.