Add office photos
Engaged Employer

Oyo Rooms

3.3
based on 3.6k Reviews
Video summary
Filter interviews by

10+ Tripwerkz Interview Questions and Answers

Updated 5 Feb 2024
Popular Designations

Q1. Candies Distribution Problem Statement

Prateek is a kindergarten teacher with a mission to distribute candies to students based on their performance. Each student must get at least one candy, and if two student...read more

Ans.

The task is to distribute candies to students based on their performance while minimizing the total candies distributed.

  • Iterate through the array of student ratings to determine the minimum number of candies required.

  • Assign each student at least one candy.

  • Adjust the number of candies based on the ratings of adjacent students to minimize the total candies distributed.

  • Example: For ratings [5, 8, 1, 5, 9, 4], the optimal distribution would be [1, 2, 1, 2, 3, 1] with a total of 1...read more

Add your answer

Q2. Boolean Matrix Transformation Challenge

Given a 2-dimensional boolean matrix mat of size N x M, your task is to modify the matrix such that if any element is 1, set its entire row and column to 1. Specifically,...read more

Ans.

Modify a boolean matrix such that if any element is 1, set its entire row and column to 1 in-place.

  • Iterate through the matrix to find elements with value 1.

  • Use additional arrays to keep track of rows and columns to be modified.

  • Update the matrix in-place based on the identified rows and columns.

Add your answer

Q3. Leaves at Same Level Problem Statement

Given a binary tree with 'N' nodes, determine if all the leaf nodes are situated at the same level. Return true if all the leaf nodes are at the same level, otherwise retu...read more

Ans.

Check if all leaf nodes in a binary tree are at the same level.

  • Traverse the binary tree and keep track of the level of each leaf node.

  • Compare the levels of all leaf nodes at the end to determine if they are at the same level.

  • Use a queue for level order traversal of the binary tree.

Add your answer

Q4. First Unique Character in a Stream Problem Statement

Given a string A consisting of lowercase English letters, determine the first non-repeating character at each point in the stream of characters.

Example:

Inp...read more
Ans.

Given a string of lowercase English letters, find the first non-repeating character at each point in the stream.

  • Iterate through the characters in the string and maintain a count of each character.

  • Use a queue to keep track of the order of characters encountered.

  • For each character, check if it is the first non-repeating character by looking at its count in the map.

  • If a character's count is 1, it is the first non-repeating character at that point in the stream.

  • Return the first n...read more

Add your answer
Discover Tripwerkz interview dos and don'ts from real experiences

Q5. Digits Decoding Problem

Ninja has a string of characters from 'A' to 'Z', encoded using their numeric values (A=1, B=2, ..., Z=26). The encoded string is given as a sequence of digits (SEQ). The task is to dete...read more

Ans.

The task is to determine the number of possible ways to decode a sequence of digits back into a string of characters from 'A' to 'Z'.

  • Use dynamic programming to keep track of the number of ways to decode the sequence at each position.

  • Consider different cases when decoding the sequence, such as single digit decoding and double digit decoding.

  • Handle edge cases like '0' and '00' appropriately.

  • Return the final count modulo 10^9 + 7 as per the constraints.

Add your answer

Q6. Maximum Non-Adjacent Subsequence Sum

Given an array of integers, determine the maximum sum of a subsequence without choosing adjacent elements in the original array.

Input:

The first line consists of an integer...read more
Ans.

Find the maximum sum of a subsequence without choosing adjacent elements in an array.

  • Use dynamic programming to keep track of the maximum sum of non-adjacent elements at each index.

  • At each index, the maximum sum is either the sum of the current element and the element two positions back, or the sum at the previous index.

  • Iterate through the array and update the maximum sum at each index accordingly.

  • Return the maximum sum found at the last index.

Add your answer
Are these interview questions helpful?

Q7. Maximum Sum of Index-Multiplied Rotations

Given an array ARR of size N, determine the maximum sum of i * ARR[i] possible through any number of rotations. Both left and right rotations are allowed, and can be pe...read more

Ans.

Find maximum sum of i * ARR[i] possible through any number of rotations in an array.

  • Calculate the sum of i * ARR[i] for each rotation and find the maximum sum.

  • Consider both left and right rotations.

  • Optimize the solution to avoid redundant calculations.

  • Handle edge cases like empty array or single element array.

Add your answer

Q8. Averages of Levels in Binary Tree Problem Statement

Given an arbitrary binary tree consisting of 'N' nodes numbered from 1 to 'N'. Each node is associated with a positive integer value. Your task is to calculat...read more

Ans.

Calculate the average of node values at each level in a binary tree.

  • Traverse the binary tree level by level using BFS

  • Calculate the sum of node values at each level and divide by the number of nodes at that level

  • Print the floor value of the average for each level

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

Q9. Cycle Detection in a Directed Graph

Given a directed graph, you need to determine whether or not the graph contains a cycle.

Your function should return true if there is at least one cycle in the graph; otherwi...read more

Ans.

Detect cycles in a directed graph and return true if a cycle exists, false otherwise.

  • Use Depth First Search (DFS) to detect cycles in the graph.

  • Maintain a visited array to keep track of visited vertices and a recursion stack to keep track of vertices in the current DFS traversal.

  • If a vertex is visited and is present in the recursion stack, then a cycle exists.

  • Example: For the input graph with vertices 0, 1, 2 and edges 0->1, 1->2, 2->0, a cycle exists among the vertices 0 -> ...read more

Add your answer

Q10. Next Permutation Problem Statement

Given a permutation of ‘N’ integers, rearrange them to generate the lexicographically next greater permutation. A sequence is a permutation if it contains all integers from 1 ...read more

Ans.

The problem involves rearranging a permutation of integers to generate the lexicographically next greater permutation.

  • Understand the concept of lexicographically next greater permutation.

  • Implement a function to find the next greater permutation.

  • Handle cases where no greater permutation exists by returning the smallest permutation.

Add your answer

Q11. Validate BST Problem Statement

Given a binary tree with N nodes, determine whether the tree is a Binary Search Tree (BST). If it is a BST, return true; otherwise, return false.

A binary search tree (BST) is a b...read more

Ans.

Validate if a binary tree is a Binary Search Tree (BST) or not.

  • Check if the left subtree of a node contains only nodes with data less than the node's data.

  • Check if the right subtree of a node contains only nodes with data greater than the node's data.

  • Recursively check if both the left and right subtrees are also binary search trees.

Add your answer

Q12. Problem Statement: Minimum Cost to Buy Ninja Blades

Ninja Yuki wants to purchase ninja blades at the Spring Fair in his village. Initially, he has 0 blades, and his goal is to buy 'N' blades. The merchant offer...read more

Ans.

Calculate the minimum cost to acquire a specific number of ninja blades using a given pricing mechanism.

  • Iterate through each test case to determine the minimum cost needed to acquire the desired number of blades.

  • Consider the cost of adding 1 blade versus doubling the current number of blades to reach the target quantity.

  • Keep track of the total cost as blades are acquired based on the pricing mechanism.

  • Return the minimum cost for each test case.

Add your answer

Q13. Rat in a Maze Problem Statement

You need to determine all possible paths for a rat starting at position (0, 0) in a square maze to reach its destination at (N-1, N-1). The maze is represented as an N*N matrix w...read more

Ans.

Find all possible paths for a rat in a maze from source to destination.

  • Use backtracking to explore all possible paths in the maze.

  • Keep track of visited cells to avoid revisiting them.

  • Recursively try moving in all directions (up, down, left, right) until reaching the destination.

  • Add the path to the result list when the destination is reached.

  • Sort the result list alphabetically before returning.

Add your answer

Q14. Minimum Cost to Destination

You are given an NxM matrix consisting of '0's and '1's. A '1' signifies that the cell is accessible, whereas a '0' indicates that the cell is blocked. Your task is to compute the mi...read more

Ans.

Find the minimum cost to reach a destination in a matrix with specified rules.

  • Use BFS traversal to explore all possible paths from the starting point to the destination.

  • Keep track of the cost incurred at each cell and update it accordingly.

  • Return the minimum cost to reach the destination or -1 if unreachable.

Add your answer

Q15. LRU Cache Design Question

Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:

1. get(key) - Return the value of the key if it exists in the cache; otherwise, re...read more

Ans.

Design a Least Recently Used (LRU) cache data structure that supports get and put operations with capacity constraint.

  • Use a combination of hashmap and doubly linked list to implement the LRU cache.

  • Keep track of the least recently used item and update it accordingly when inserting new items.

  • Ensure to handle the capacity constraint by evicting the least recently used item when the cache is full.

  • Implement get(key) and put(key, value) operations as per the LRU cache design requir...read more

Add your answer

Q16. Longest Increasing Subsequence Problem Statement

Given an array of integers with 'N' elements, determine the length of the longest subsequence where each element is greater than the previous element. This subse...read more

Ans.

Find the length of the longest strictly increasing subsequence in an array of integers.

  • Use dynamic programming to keep track of the longest increasing subsequence ending at each element.

  • Initialize an array to store the length of the longest increasing subsequence ending at each index.

  • Iterate through the array and update the length of the longest increasing subsequence for each element.

  • Return the maximum value in the array as the length of the longest increasing subsequence.

Add your answer
Q17. Given the employee and department tables, how would you find the number of employees in each department? (This question focuses on SQL Joins.)
Ans.

Use SQL Joins to find the number of employees in each department.

  • Use a JOIN statement to combine the employee and department tables based on the department ID.

  • Group the results by department ID and use COUNT() function to find the number of employees in each department.

  • Example: SELECT department.department_id, COUNT(employee.employee_id) AS num_employees FROM department JOIN employee ON department.department_id = employee.department_id GROUP BY department.department_id;

Add your answer
Q18. What is the difference between Mutex and Semaphores?
Ans.

Mutex is used for exclusive access to a resource by only one thread at a time, while Semaphores can allow multiple threads to access a resource simultaneously.

  • Mutex is binary and can be locked by only one thread at a time, while Semaphores can have a count greater than one.

  • Mutex is used for protecting critical sections of code, while Semaphores can be used for controlling access to a pool of resources.

  • Mutex is simpler to use but can lead to deadlocks, while Semaphores are mor...read more

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Intern Interview Questions from Similar Companies

3.9
 • 46 Interview Questions
3.9
 • 21 Interview Questions
3.9
 • 17 Interview Questions
4.5
 • 16 Interview Questions
3.7
 • 12 Interview Questions
4.2
 • 11 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
75 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