
Hike

20+ Hike Software Developer Interview Questions and Answers
Q1. Reverse Words in a String: Problem Statement
You are given a string of length N
. Your task is to reverse the string word by word. The input may contain multiple spaces between words and may have leading or trai...read more
Reverse words in a string by reversing the order of words while maintaining spaces.
Split the input string by spaces to get individual words
Reverse the order of the words
Join the reversed words with a single space in between
Q2. Average Marks Problem Statement
Given the initial letter of a student's name and three integer marks for that student, calculate and display the student's initial letter followed by the integer part of their av...read more
Calculate and display the student's initial letter followed by the integer part of their average marks.
Calculate the average of the three marks provided for each student.
Display the initial letter of the student's name followed by the integer part of the average marks.
Round down the average to the nearest integer to get the integer part.
Q3. K Largest Elements Problem Statement
Given an unsorted array containing 'N' integers, you are required to find 'K' largest elements from the array and return them in non-decreasing order.
Input:
The first line ...read more
Find K largest elements in an unsorted array and return them in non-decreasing order.
Sort the array in non-decreasing order
Return the last K elements of the sorted array
Q4. Next Greater Number Problem Statement
Given a string S
which represents a number, determine the smallest number strictly greater than the original number composed of the same digits. Each digit's frequency from...read more
Given a number represented as a string, find the smallest number greater than the original with the same set of digits.
Sort the digits in non-increasing order to find the next greater number.
Swap the last two digits to get the smallest greater number.
If no greater number exists, return -1.
Q5. Level Order Traversal Problem Statement
Given a binary tree of integers, return the level order traversal of the binary tree.
Input:
The first line contains an integer 'T', representing the number of test cases...read more
Return the level order traversal of a binary tree given in level order with null nodes represented by -1.
Parse the input to create the binary tree using level order traversal
Use a queue to perform level order traversal and print the nodes in the order visited
Handle null nodes represented by -1 appropriately
Q6. Peak Element Finder
For a given array of integers arr
, identify the peak element. A peak element is an element that is greater than its neighboring elements. Specifically, if arr[i]
is the peak, then both arr[i...read more
Find the peak element in an array of integers.
Iterate through the array and check if the current element is greater than its neighbors.
Handle edge cases for the first and last elements of the array.
Return the peak element found.
Q7. Statistics From A Large Sample Task
Calculate various statistical measures given a large sample of integers in the range [0, 255]. For efficiency, you are provided with an array 'count' where the i-th element s...read more
Calculate various statistical measures given a large sample of integers in the range [0, 255] using the provided frequency array.
Iterate through the 'count' array to calculate minimum and maximum values.
Calculate the mean by summing up all values and dividing by the total count.
Find the median by sorting the sample and determining the middle element(s).
Identify the mode by finding the element with the highest frequency.
Ensure precision up to 5 decimal places in the output.
Q8. Pair Sum in Binary Search Tree
Given a Binary Search Tree (BST) and a target value 'K', determine if there exist two unique elements in the BST such that their sum equals the target 'K'.
Explanation:
A BST is a...read more
Given a BST and a target value, determine if there exist two unique elements in the BST such that their sum equals the target.
Traverse the BST in-order to get a sorted array of elements.
Use two pointers approach to find the pair sum in the sorted array.
Keep track of visited elements to ensure uniqueness.
Handle edge cases like null nodes and empty tree.
Example: For input BST [20, 10, 35, 5, 15, 30, 42, -1, 13, -1, -1, -1, -1, -1, -1, -1] and K = 45, output true.
Q9. Number of Islands II Problem Statement
You have a 2D grid of dimensions 'N' rows by 'M' columns, initially filled with water. You are given 'Q' queries, where each query contains two integers 'X' and 'Y'. Durin...read more
The task is to determine the number of islands present on a 2D grid after each query of converting water to land.
Create a function that takes the grid dimensions, queries, and coordinates as input.
For each query, convert the water at the given coordinates to land and update the grid.
Use depth-first search (DFS) to find connected lands and count the number of islands.
Return the number of islands after each query.
Q10. Ninja and Sorted Array Merging Problem
Ninja is tasked with merging two given sorted integer arrays ARR1
and ARR2
of sizes 'M' and 'N', respectively, such that the merged result is a single sorted array within ...read more
Merge two sorted arrays into one sorted array within the first array.
Create a pointer for the last index of ARR1 and ARR2 to start merging from the end.
Compare elements from both arrays and place the larger element at the end of ARR1.
Continue this process until all elements are merged in sorted order within ARR1.
Q11. Reverse Alternate Levels of a Perfect Binary Tree Problem Statement
Given a perfect binary tree consisting of 'N' nodes, reverse the nodes at alternate levels in the tree (i.e., reverse level 2, level 4, level ...read more
Reverse alternate levels of a perfect binary tree by reversing nodes at even levels starting from level 2.
Traverse the tree in level order and store nodes at even levels in a separate list.
Reverse the list of nodes at even levels.
Update the tree with the reversed nodes at even levels.
Repeat the process for alternate levels starting from level 2.
Q12. 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
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 efficiently 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.
Q13. Binary Tree Traversals
Your task is to compute the In-Order, Pre-Order, and Post-Order traversals for a given Binary Tree with 'N' nodes, where each node has an integer value.
Input:
T For each test case, the i...read more
Compute In-Order, Pre-Order, and Post-Order traversals for a given Binary Tree with 'N' nodes.
Implement tree traversal algorithms: In-Order, Pre-Order, and Post-Order.
Use recursion to traverse the binary tree efficiently.
Handle null nodes represented by -1 in the input.
Follow the order of nodes as they appear in the level order traversal.
Ensure the output is space-separated lists for each traversal type.
Q14. Sorting of a Rotated Sorted Array Problem Statement
You are provided with a rotated sorted array of size N
. Your task is to sort the given array in increasing order.
Example:
Input:
N = 4
Array = [2, 3, 4, 1]
Ou...read more
Implement a function to sort a rotated sorted array in increasing order without using the sort() function.
Find the pivot element in the rotated sorted array.
Split the array into two subarrays based on the pivot element.
Sort each subarray separately.
Merge the sorted subarrays to get the final sorted array.
Q15. Running Median Problem
Given a stream of integers, calculate and print the median after each new integer is added to the stream.
Output only the integer part of the median.
Example:
Input:
N = 5
Stream = [2, 3,...read more
Calculate and print the median after each new integer is added to the stream.
Use two heaps - a max heap to store the smaller half of the numbers and a min heap to store the larger half.
Keep the sizes of the two heaps balanced to efficiently calculate the median.
If the total number of elements is odd, the median will be the top element of the max heap.
If the total number of elements is even, the median will be the average of the top elements of the two heaps.
5 pirates must divide 100 gold coins based on ranking and rules.
Pirate 1 proposes a distribution, all pirates (including the proposer) vote on it. If majority agree, coins are distributed. If not, Pirate 1 is thrown overboard and Pirate 2 proposes a new distribution.
Pirates are ranked by seniority, with Pirate 1 being the most senior.
Pirates prioritize staying alive over getting gold, but also want to maximize their share of gold.
Example: Pirate 1 proposes 98 coins for himsel...read more
Producer-Consumer problem involves multiple threads sharing a common buffer. Producers add items to the buffer while consumers remove them.
Producers and consumers need to synchronize their access to the shared buffer to avoid race conditions.
Semaphores can be used to control access to the buffer. Two semaphores are used - one to track the empty slots in the buffer and one to track the filled slots.
Producers increment the empty semaphore count when they add an item to the buff...read more
Characteristics of distributed file systems include scalability, fault tolerance, and data replication.
Scalability: Distributed file systems can easily scale to accommodate a large amount of data and users.
Fault tolerance: They are designed to continue functioning even if some components fail, ensuring high availability.
Data replication: Data is often replicated across multiple nodes to ensure reliability and performance.
Consistency: Distributed file systems must maintain con...read more
Analyzing usage history involves tracking user interactions, patterns, and trends to improve application performance.
Collect and store user interaction data such as clicks, page views, and time spent on each feature.
Use analytics tools to generate reports and visualize usage patterns.
Identify popular features, user preferences, and areas for improvement based on usage data.
Implement A/B testing to compare different versions of features and analyze user behavior.
Utilize machin...read more
Synchronized blocks are needed in Java to ensure thread safety by allowing only one thread to access a block of code at a time.
Prevents multiple threads from accessing critical sections of code simultaneously
Ensures data consistency and prevents race conditions
Improves performance by reducing contention for shared resources
Example: synchronized block in a method that updates a shared variable
ConcurrentHashMap is a thread-safe implementation of the Map interface in Java.
ConcurrentHashMap allows multiple threads to read and write to the map concurrently without causing any issues like deadlocks or data corruption.
It achieves thread-safety by dividing the map into segments, each of which can be locked independently.
ConcurrentHashMap is more efficient than using synchronized maps for concurrent access.
Example: ConcurrentHashMap<String, Integer> map = new ConcurrentHa...read more
Design a file sharing mechanism between two users.
Implement a secure login system for both users.
Allow users to upload files to a shared server.
Provide a way for users to view and download files shared by the other user.
Implement access control to ensure only authorized users can access the shared files.
Q23. Largest vertical rectangle in array
Find the largest vertical rectangle in an array of strings
Iterate through each column in the array
For each column, find the consecutive vertical rectangles of '1's
Calculate the area of each rectangle and keep track of the largest one
Interview Process at Hike Software Developer

Top Software Developer Interview Questions from Similar Companies







Reviews
Interviews
Salaries
Users/Month

