Meesho Coding Questions and Answers

Meesho Coding Questions with Solutions

Here on this page you will get Sample Meesho coding questions and answers which will help you to prepare for Online Coding Assessment of Meesho to hire freshers for SDE Role.

Let you know that the Online Assessment will be conducted on Hackerearth Platform. After Resume Shortlisting Candidates will be communicated through mail for Online Assessment on Hackerearth.

meesho coding questions with solutions

Meesho Hiring 2025 Details

  • Role: SDE Trainee (6-month traineeship)

  • Stipend: ₹1,00,000 per month

  • Location: Bengaluru (Hybrid, 3 days in-office)

  • Eligibility: B.E/B.Tech/M.E/M.Tech (CSE, IT, ECE, EEE, E&I) & MCA (2024 & 2025 batch)

  • Selection Process:

    1. Application Submission
    2. HackerEarth Coding Test
    3. Technical & Hiring Manager Interview
    4. Offer Letter Rollout
  • Full-Time Opportunity: Based on performance, FTE offer with ₹20 LPA + benefits

  • Key Dates:

    • Apply by: 14th March 2025
    • Coding Test: 22nd March 2025
    • Interviews: 4th – 11th April 2025
    • Offer Rollout: 12th April 2025

Note: No active backlogs allowed. Candidates who participated in Meesho hiring in the last 6 months are not eligible.

Checkout PrepInsta Prime:

Practice Coding Questions:

Further on this page you will get Sample Meesho Coding Questions and Answers that will help you to prepare for Meesho Online Coding Assessment on Hackerearth Platform.

Sample Meesho Coding Questions with Solutions

Question 1: Program to check Valid Palindrome.

Given a string s, return true if it is a palindrome, otherwise return false.

A palindrome is a string that reads the same forward and backward. It is also case-insensitive and ignores all non-alphanumeric characters.

Explanation: After considering only alphanumerical characters we have “wasitacaroracatisaw”, which is a palindrome.

Constraints:

  • 1 <= s.length <= 1000
  • s is made up of only printable ASCII characters.
Solution:
Reverse String Method

This approach involves reversing the string representation of the array elements, sorting the reversed strings, and then checking for the longest consecutive sequence. However, it’s not commonly used for this problem as it focuses on string manipulation.

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

Code

Question 2: Buying and Selling Stocks Problem.

You are given an array prices, where each element prices[i] represents the price of PrepCoin on the i-th day.

Your task is to determine the maximum profit you can make by selecting one day to buy a PrepCoin and another day after it to sell.

If it’s not possible to make any profit (e.g., prices are decreasing every day), you should return 0. This means you can also choose not to make any transactions.

Explanation : No profitable transactions can be made, thus the max profit is 0.

Constraints:

  • 1 <= prices.length <= 100
  • 0 <= prices[i] <= 100
Solution:
Method 1: Two Pointers Method

Use a single pass with two variables to track the minimum price so far and the maximum profit, updating them as you traverse the array. This has a time complexity of O(n).

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

Code

Method 2: Dynamic Programming Method

This method maintain a table or array to store intermediate results, such as the minimum price up to a given day and the maximum profit calculated so far, optimizing computation over multiple traversals. Time complexity is O(n).

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

Code

Question 3: Program for Koko Eating Bananas Problem

You are given an array piles, where each element piles[i] represents the number of bananas in the i-th pile. You also have h hours to eat all the bananas. You can choose an eating rate of k bananas per hour. In each hour, you can eat up to k bananas from one pile.

If a pile has fewer than k bananas, you finish that pile but cannot switch to another pile during the same hour.

Your task is to find the minimum value of k that allows you to eat all the bananas within h hours.

Explanation: 

With an eating rate of 2, you can eat the bananas in 6 hours. With an eating rate of 1, you would need 10 hours to eat all the bananas (which exceeds h=9), thus the minimum eating rate is 2.

Constraints:

  • 1 <= piles.length <= 1,000
  • piles.length <= h <= 1,000,000
  • 1 <= piles[i] <= 1,000,000,000
Solution:
Using Binary Search Method

Use binary search to find the minimum eating speed by searching between 1 and the maximum pile size, checking the feasibility of each mid-speed.

  • Time complexity: O(n * log m)
  • Space complexity: O(1)

where n is the length of the input array piles and m is the maximum number of bananas in a pile.

Code

Sample Meesho Coding Questions

Question 4: Power Function (Pow(x, n))

Implement a function pow(x, n) that calculates x raised to the power n (i.e., x^n).

Constraints :

  • -100.0 < x < 100.0

  • -231 <= n <= 231-1

  • n is an integer.

  • Either x is not zero or n > 0.

  • -104 <= xn <= 104

Solution:

Question 5: Course Schedule Problem of Graphs.

You are given an array prerequisites, where each element prerequisites[i] = [a, b] means you must complete course b before taking course a.

For example, [0, 1] indicates that course 1 must be completed before course 0.

There are a total of numCourses, labeled from 0 to numCourses – 1. Return true if it is possible to complete all courses; otherwise, return false.

Explanation: First take course 1 (no prerequisites) and then take course 0.

Constraints :

  • 1 <= numCourses <= 1000
  • 0 <= prerequisites.length <= 1000
  • All prerequisite pairs are unique.
Solution:
Solving by Cycle Detection(DFS) Method

Treat the courses as a graph and use DFS to detect cycles. Maintain a visited set to track the current path during DFS. If a course is revisited in the same path, a cycle exists, making it impossible to complete all courses.

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

where V is the number of courses and E is the number of prerequisites.

Code

Question 6: Counting the Number of 1’s in Binary Representations of Numbers in a Range

Understanding binary numbers and efficiently processing them is a critical skill.

Common problem involves counting how many 1 bits are present in the binary representation of numbers within a given range.In this article, we will explore a solution to count the number of 1 bits in every number from 0 to n.

We need to count the number of 1 bits in the binary representations of numbers from 0 to 4. Let’s convert these numbers to binary:

  • 0 in binary: 0 → Number of 1 bits: 0
  • 1 in binary: 1 → Number of 1 bits: 1
  • 2 in binary: 10 → Number of 1 bits: 1
  • 3 in binary: 11 → Number of 1 bits: 2
  • 4 in binary: 100 → Number of 1 bits: 1

Solution:

Method 1. Bit Mask – I

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

Method 2. Built-In Function

Time & Space Complexity

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

Code

Meesho Coding Questions and Answers

Question 7: Print all combinations of balanced parentheses problem

You are given a positive integer n, representing the number of pairs of parentheses. Your task is to generate and return all possible combinations of well-formed (valid) parentheses strings that can be created using exactly n pairs.

A well-formed parentheses string maintains the correct order, meaning every opening parenthesis ( has a corresponding closing parenthesis ) that appears after it.

Explanation: You may return the answer in any order.

Constraints:

  • 1 <= n <= 7

Solution:

Using Dynamic Programming Method

Construct valid combinations using previously computed solutions for smaller values of n, combining them in different ways to form well-balanced parentheses for the current n.

  • Time complexity: O(4^n/(n)^1/2)
  • Space complexity: O(n)

Code

Question 8: LRU Cache Leetcode Problem

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

Implement the LRUCache class:

  1. LRUCache(int capacity) Initialize the LRU cache with positive size capacity.
  2. int get(int key) Return the value of the key if the key exists, otherwise return -1.
  3. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache.
  4. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
  5. The functions get and put must each run in O(1) average time complexity.

Constraints :

  • 1 <= capacity <= 3000
  • 0 <= key <= 104
  • 0 <= value <= 105
  • At most 2 * 105 calls will be made to get and put.

Solution:

Question 9: Encode and Decode Strings Problem

Design an algorithm to encode a list of strings to a single string. The encoded string is then decoded back to the original list of strings. Please implement encode and decode.

Constraints:

  • 0 <= strs.length < 100
  • 0 <= strs[i].length < 200
  • strs[i] contains only UTF-8 characters.

Solution:

Solving Encoding and Decoding Method

This method use a delimiter (like a special character or length-prefix) to encode strings, and split the encoded string using the same delimiter to decode. Simple but may face issues with delimiter conflicts.

  • Time complexity: O(m) for encode() and decode().
  • Space complexity: O(n) for encode() and decode().

where m is the sum of lengths of all the strings and n is the number of strings.

Code

Sample Meesho Coding Questions and Answers

Question 10: Kth Largest Element in an Array

Given an integer array nums and an integer k, return the kth largest element in the array.

Note that it is the kth largest element in the sorted order, not the kth distinct element.

Can you solve it without sorting?

Constraints :

  • 1 <= k <= nums.length <= 10^5
  • -10^4 <= nums[i] <= 10^4

These were some of most Important Meesho Coding Questions and Answers. If you want to practice more you can visit our coding blogs to explore more….and also visit PrepInsta Prime Course.

FAQ's related to Meesho Coding Assessment

Question 1. What types of coding questions are asked in the Meesho hiring process?

Answer:

Meesho Coding Questions mainly includes topics like arrays, strings, dynamic programming, graphs, and recursion.

Problems can range from easy to hard, depending on the role you are applying for.

Question 2. Which programming languages are allowed for the meesho coding test?

Answer:

  • Meesho allows candidates to code in multiple languages, including Java, Python and JavaScript.
  • It is best to use one of these three languages that you are comfortable with and has built-in support for efficient data structures.

Question 3. How can I prepare for Meesho coding round?

Answer:

To prepare effectively:

  • Practice Coding Questions from our PrepInsta’s Coding Dashboard.
  • Focus on Time & Space Complexity of solutions.
  • Revise important algorithms like Binary Search, Two Pointers, and Graph Traversal.