Add office photos
Engaged Employer

Mobikwik

4.0
based on 443 Reviews
Filter interviews by

10+ Workfreaks Corporate Service Interview Questions and Answers

Updated 5 Feb 2024

Q1. Sort 0 and 1 Problem Statement

Given an integer array ARR of size N containing only integers 0 and 1, implement a function to sort this array. The solution should scan the array only once without using any addi...read more

Ans.

Sort an array of 0s and 1s in linear time without using additional arrays.

  • Iterate through the array and maintain two pointers, one for 0s and one for 1s.

  • Swap elements at the two pointers based on the current element being 0 or 1.

  • Continue this process until the entire array is sorted in place.

View 1 answer

Q2. Maximum Frequency Number Problem Statement

Given an array of integers with numbers in random order, write a program to find and return the number which appears the most frequently in the array.

If multiple elem...read more

Ans.

Find the number with the maximum frequency in an array of integers.

  • Iterate through the array and keep track of the frequency of each number using a hashmap.

  • Find the number with the maximum frequency and return it.

  • If multiple elements have the same maximum frequency, return the one that appears first.

Add your answer

Q3. Maximum Subarray Sum Problem Statement

Given an array of integers, determine the maximum possible sum of any contiguous subarray within the array.

Example:

Input:
array = [34, -50, 42, 14, -5, 86]
Output:
137
E...read more
Ans.

Find the maximum sum of any contiguous subarray within an array of integers.

  • Iterate through the array and keep track of the maximum sum of subarrays encountered so far.

  • At each index, decide whether to include the current element in the subarray or start a new subarray.

  • Update the maximum sum if a new maximum is found.

  • Example: For array [34, -50, 42, 14, -5, 86], the maximum sum is 137.

  • Example: For array [-5, -1, -8, -9], the maximum sum is -1.

Add your answer

Q4. Reverse Linked List Problem Statement

Given a singly linked list of integers, return the head of the reversed linked list.

Example:

Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Ans.

Reverse a singly linked list of integers and return the head of the reversed linked list.

  • Iterate through the linked list and reverse the pointers to point to the previous node instead of the next node.

  • Use three pointers to keep track of the current, previous, and next nodes while reversing the linked list.

  • Update the head of the reversed linked list as the last node encountered during the reversal process.

Add your answer
Discover Workfreaks Corporate Service interview dos and don'ts from real experiences

Q5. Shortest Path in a Binary Matrix Problem Statement

Given a binary matrix of size N * M where each element is either 0 or 1, find the shortest path from a source cell to a destination cell, consisting only of 1s...read more

Ans.

Find the shortest path in a binary matrix from a source cell to a destination cell consisting only of 1s.

  • Use Breadth First Search (BFS) to explore all possible paths from the source cell to the destination cell.

  • Keep track of visited cells to avoid revisiting them.

  • Update the path length as you traverse through the matrix.

  • Return the shortest path length found or -1 if no valid path exists.

Add your answer

Q6. Trapping Rain Water

You are provided with an array ARR of integers representing an elevation map, where ARR[i] denotes the elevation of the ith bar. Determine the maximum amount of rainwater that can be trapped...read more

Ans.

Given an array representing an elevation map, find the maximum amount of rainwater that can be trapped between the bars.

  • Iterate through the array and calculate the maximum height on the left and right of each bar.

  • Calculate the trapped water by finding the minimum of the maximum heights on the left and right minus the current bar height.

  • Sum up the trapped water for all bars to get the total trapped rainwater.

  • Example: For input [0, 1, 0, 2], the trapped rainwater is 1 unit.

  • Exam...read more

Add your answer
Are these interview questions helpful?

Q7. Buy and Sell Stock Problem Statement

Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell transa...read more

Ans.

The task is to determine the maximum profit that can be achieved by performing up to two buy-and-sell transactions on a given set of stock prices.

  • Iterate through the array of stock prices to find the maximum profit that can be achieved by buying and selling stocks.

  • Keep track of the maximum profit that can be obtained by performing two transactions.

  • Consider all possible combinations of buying and selling stocks to maximize profit.

  • Ensure to sell the stock before buying again to...read more

Add your answer

Q8. Ninja and Bombs Problem Statement

Ninja wants to travel from his house to his best friend's house. The locations of the houses are on a 2D coordinate plane, where Ninja's house is located at the origin (0, 0). ...read more

Ans.

Determine if Ninja can reach his friend's house with even x-coordinate without using modulus operator.

  • Check if the x-coordinate is even or odd by using bitwise AND operation with 1.

  • Return 1 if x-coordinate is even, else return 0.

  • Handle multiple test cases by iterating through each input.

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Valid Perfect Square Check

An integer N is provided, and the task is to determine if N is a perfect square. A perfect square refers to an integer which can be expressed as the square of another integer.

Sample ...read more

Ans.

Implement a function to check if a given integer is a perfect square.

  • Create a function that takes an integer as input and returns true if it is a perfect square, false otherwise.

  • Iterate through possible square roots of the input integer and check if the square of the root equals the input.

  • Return true if a perfect square is found, false otherwise.

Add your answer

Q10. Bottom View of Binary Tree Problem Statement

Given a binary tree, the task is to print its bottom view from left to right. Assume the left and the right child nodes make a 45-degree angle with their parent node...read more

Ans.

The task is to print the bottom view of a binary tree from left to right.

  • Traverse the binary tree in level order and keep track of the horizontal distance of each node from the root.

  • Store the nodes at each horizontal distance in a map, updating it as you traverse the tree.

  • After traversal, extract the bottom-most nodes at each horizontal distance to get the bottom view sequence.

Add your answer

Q11. Longest Substring with At Most K Distinct Characters

Given a string S of length N and an integer K, find the length of the longest substring that contains at most K distinct characters.

Input:

The first line co...read more
Ans.

Find the length of the longest substring with at most K distinct characters in a given string.

  • Use a sliding window approach to keep track of the characters and their counts within the window.

  • Maintain a hashmap to store the characters and their frequencies.

  • Update the window size and characters count as you iterate through the string.

  • Return the maximum window size encountered for each test case.

Add your answer

Q12. Kth Smallest Element Problem Statement

You are provided with an array of integers ARR of size N and an integer K. Your task is to find and return the K-th smallest value present in the array. All elements in th...read more

Ans.

Find the K-th smallest element in an array of distinct integers.

  • Sort the array and return the element at index K-1.

  • Use a min-heap to find the K-th smallest element efficiently.

  • Implement quickselect algorithm for optimal performance.

Add your answer

Q13. Merge Sort Problem Statement

Given a sequence of numbers 'ARR', your task is to return a sorted sequence of 'ARR' in non-descending order using the Merge Sort algorithm.

Example:

Input:
ARR = [5, 3, 8, 6, 2]
Ou...read more
Ans.

Implement Merge Sort algorithm to sort a given sequence of numbers in non-descending order.

  • Merge Sort is a divide-and-conquer algorithm that splits the array into two halves, recursively sorts each half, and then merges the sorted halves back together.

  • Time complexity of Merge Sort is O(n log n) in the worst case scenario.

  • It is a stable sorting algorithm, meaning that the relative order of equal elements is preserved.

  • Example: Input: [5, 3, 8, 6, 2], Output: [2, 3, 5, 6, 8]

Add your answer

Q14. Find Duplicates in an Array

Given an array ARR of size 'N', where each integer is in the range from 0 to N - 1, identify all elements that appear more than once.

Return the duplicate elements in any order. If n...read more

Ans.

Find duplicates in an array of integers within a specified range.

  • Iterate through the array and keep track of the count of each element using a hashmap.

  • Return elements with count greater than 1 as duplicates.

  • Time complexity can be optimized to O(N) using a set to store seen elements.

Add your answer
Q15. How would you implement various activities related to cart functionality in an e-commerce application?
Ans.

Implementing cart functionality in an e-commerce application involves managing user interactions, updating quantities, handling discounts, and processing orders.

  • Create a data structure to store cart items, quantities, and prices.

  • Implement add to cart, remove from cart, and update quantity functionalities.

  • Handle discounts, promotions, and coupon codes.

  • Calculate total price, including taxes and shipping costs.

  • Implement checkout process to place orders and update inventory.

  • Consi...read more

Add your answer
Q16. How would you implement multiple RecyclerViews on a magnified screen in an Android application?
Ans.

Implement multiple RecyclerViews on a magnified screen in an Android app by adjusting item sizes and spacing.

  • Adjust item sizes and spacing based on screen magnification level

  • Use nested RecyclerViews or custom layouts to display multiple lists

  • Implement custom item decorators to manage spacing between RecyclerViews

  • Consider using a GridLayoutManager with custom span sizes for each RecyclerView

Add your answer
Q17. Can you design a Google Search Engine?
Ans.

Designing a Google Search Engine involves creating a web crawler, indexing system, and ranking algorithm.

  • Develop a web crawler to discover and retrieve web pages.

  • Implement an indexing system to store and organize the content of web pages.

  • Design a ranking algorithm to determine the relevance of search results.

  • Include features like autocomplete, spell check, and personalized search results.

  • Optimize for speed and scalability to handle large amounts of data and user queries.

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Workfreaks Corporate Service

based on 1 interviews
Interview experience
5.0
Excellent
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

3.7
 • 30 Interview Questions
3.7
 • 23 Interview Questions
3.9
 • 17 Interview Questions
4.3
 • 15 Interview Questions
3.7
 • 12 Interview Questions
3.8
 • 12 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter