Add office photos
Hike logo
Employer?
Claim Account for FREE

Hike

3.6
based on 56 Reviews
Filter interviews by
Designation
Fresher
Experienced
Skills
Clear (1)

10+ Hike Interview Questions and Answers for Freshers

Updated 5 Feb 2024
Popular Designations

Q1. Maximum Size Rectangle Sub-matrix with All 1's Problem Statement

You are provided with an N * M sized binary matrix 'MAT' where 'N' denotes the number of rows and 'M' denotes the number of columns. Your task is...read more

Ans.

Find the maximum area of a submatrix with all 1's in a binary matrix.

  • Iterate over each cell in the matrix and calculate the maximum area of submatrix with that cell as the top-left corner.

  • Use dynamic programming to keep track of the maximum width of 1's ending at each cell.

  • Update the maximum area as you iterate through the matrix.

  • Return the maximum area found.

Add your answer
right arrow

Q2. Minimum Number of Swaps to Sort an Array

Find the minimum number of swaps required to sort a given array of distinct elements in ascending order.

Input:

T (number of test cases)
For each test case:
N (size of the...read more
Ans.

The minimum number of swaps required to sort a given array of distinct elements in ascending order.

  • Use a graph-based approach to find cycles in the array for swapping

  • Count the number of swaps needed to sort the array

  • Example: For [4, 3, 2, 1], 2 swaps are needed to sort it to [1, 2, 3, 4]

Add your answer
right arrow

Q3. Binary Tree Maximum Path Sum Problem Statement

Determine the maximum path sum for any path in a given binary tree with 'N' nodes.

Note:

  • A 'path' is defined as any sequence of adjacent nodes connected by an edg...read more
Ans.

Find the maximum path sum in a binary tree with 'N' nodes.

  • Traverse the binary tree to find the maximum path sum.

  • Keep track of the maximum sum encountered so far.

  • Consider all possible paths in the tree to find the maximum sum.

  • Example: For input 1 2 3 4 -1 5 6 -1 -1 -1 -1 -1 -1, the maximum path sum is 16.

Add your answer
right arrow

Q4. Maximum Sum Path in a Binary Tree

Your task is to determine the maximum possible sum of a simple path between any two nodes (possibly the same) in a given binary tree of 'N' nodes with integer values.

Explanati...read more

Ans.

Find the maximum sum of a simple path between any two nodes in a binary tree.

  • Use a recursive approach to traverse the binary tree and calculate the maximum sum path.

  • Keep track of the maximum sum path found so far while traversing the tree.

  • Consider negative values in the path sum calculation to handle cases where the path can skip nodes.

  • Update the maximum sum path if a new path with a higher sum is found.

Add your answer
right arrow
Discover Hike interview dos and don'ts from real experiences

Q5. Infix to Postfix Conversion

Convert a given infix expression, represented as a string EXP, into its equivalent postfix expression.

Explanation:

An infix expression is formatted as a op b where the operator is p...read more

Ans.

Convert infix expression to postfix expression.

  • Use a stack to keep track of operators and operands.

  • Follow the rules of precedence for operators.

  • Handle parentheses to ensure correct order of operations.

Add your answer
right arrow

Q6. Maximum Size Rectangle Sub-Matrix with All 1's

Given an N x M binary matrix 'MAT', where N is the number of rows and M is the number of columns, determine the maximum area of a submatrix consisting entirely of ...read more

Ans.

Find the maximum area of a submatrix consisting entirely of 1's in a binary matrix.

  • Iterate over each cell in the matrix and calculate the maximum area of a submatrix with that cell as the top-left corner.

  • Use dynamic programming to keep track of the maximum width of 1's ending at each cell in the current row.

  • Update the maximum area as you iterate through the matrix and consider each cell as the bottom-right corner of the submatrix.

Add your answer
right arrow
Are these interview questions helpful?

Q7. Prefix to Infix Conversion

Transform a string representing a valid Prefix expression, which may contain operators '+', '-', '*', '/', and uppercase letters, into its corresponding Infix expression.

Example:

Inp...read more
Ans.

Convert a valid Prefix expression to its corresponding Infix expression.

  • Use a stack to store operands and operators while traversing the prefix expression from right to left.

  • Pop operands from the stack and form the infix expression by placing them between corresponding operators.

  • Handle the precedence of operators to ensure correct order of operations in the infix expression.

Add your answer
right arrow

Q8. Maximum Difference in Matrix

Given an n x n matrix mat[n][n] of integers, find the maximum value of mat[c][d] - mat[a][b] for all possible indices where c > a and d > b.

Input:

The first line contains a single ...read more
Ans.

Find the maximum difference between elements in a matrix with specific conditions.

  • Iterate through all possible pairs of indices (a, b) and (c, d) where c > a and d > b.

  • Calculate the difference between mat[c][d] and mat[a][b] for each pair.

  • Keep track of the maximum difference found so far.

  • Return the maximum difference as the final result.

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Write code to get maximum and second maximum element of a stack. The given function should be in O(1) complexity

Ans.

Code to get max and second max element of a stack in O(1) complexity.

  • Create two variables to store max and second max values

  • Update the variables whenever a new element is pushed or popped from the stack

  • Return the max and second max values when required

Add your answer
right arrow

Q10. Given a biotonic array ( first numbers increase and then decrease ) write code to search a given number. Time complexity O(logn)

Ans.

Code to search a given number in a biotonic array with O(logn) time complexity.

  • Use binary search to find the peak element in the array.

  • Divide the array into two subarrays and perform binary search on each subarray.

  • Return the index of the element if found, else return -1.

Add your answer
right arrow

Q11. A sorted array is rotated K times. Sort it in o(n) traversal without extra space

Ans.

Sort a rotated sorted array in O(n) time without extra space

  • Find the index of the minimum element using binary search

  • Reverse the two subarrays on either side of the minimum element

  • Reverse the entire array

  • Example: [4,5,6,7,0,1,2] -> [0,1,2,4,5,6,7]

Add your answer
right arrow

Q12. two pair with a given sum in a bst with o(log n) space

Ans.

Finding two pairs with a given sum in a BST using O(log n) space.

  • Traverse the BST in-order and store the nodes in an array

  • Use two pointers approach to find the pairs with the given sum

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

  • Optimized approach: Use two stacks to traverse the BST in-order and find the pairs

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

Add your answer
right arrow

Q13. K random numbers from infinite stream of array with equal probability

Ans.

To select k random numbers from an infinite stream of array with equal probability.

  • Use reservoir sampling algorithm to randomly select k numbers from the stream

  • Maintain a reservoir array of size k to store the selected numbers

  • For each incoming number, generate a random number between 0 and the total count of numbers seen so far

  • If the generated number is less than k, replace the corresponding number in the reservoir array with the incoming number

  • At the end, the reservoir array...read more

Add your answer
right arrow

Q14. Why manhole is round ?

Ans.

Manholes are round because it prevents them from falling into the hole and allows for easy movement of the cover.

  • Round covers cannot fall into the hole as they cannot fit through diagonally

  • Round covers can be easily moved in any direction

  • Round shape distributes weight evenly

  • Round shape is easier to manufacture and install

Add your answer
right arrow

Q15. Median of a stream of array

Ans.

Finding the median of a stream of array in real-time.

  • Use two heaps to keep track of the median

  • Maintain a max heap for the lower half and a min heap for the upper half

  • If the heaps are balanced, the median is the average of the top elements of both heaps

  • If the heaps are unbalanced, the median is the top element of the heap with more elements

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

Top Interview Questions from Similar Companies

Paytm Logo
3.3
 • 458 Interview Questions
TCE Logo
3.8
 • 211 Interview Questions
Hindustan Unilever  Logo
4.2
 • 173 Interview Questions
Standard Chartered Logo
3.7
 • 169 Interview Questions
Tata Elxsi Logo
3.8
 • 157 Interview Questions
View all
Recently Viewed
REVIEWS
Shriram Finance
No Reviews
REVIEWS
Shriram Finance
No Reviews
SALARIES
Hexaware Technologies
INTERVIEWS
BNY
Fresher
20 top interview questions
REVIEWS
Omega Healthcare
No Reviews
INTERVIEWS
Delhivery
No Interviews
SALARIES
Morgan Stanley
SALARIES
Ernst & Young
SALARIES
Ernst & Young
SALARIES
Boston Scientific
Top Hike Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
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