Hike
80+ Interview Questions and Answers
Q1. Design an photo viewing app which will show images from the disk in the list, and one item in the list should take half of the screen. (Android app design question, have to explain all the components used in it...
read moreAn Android photo viewing app with a list of images from disk, one taking half the screen.
Use RecyclerView to display the list of images
Use a custom adapter to bind the images to the RecyclerView
Use a GridLayoutManager with span count of 2 to achieve the half-screen effect
Load images from disk using a library like Glide or Picasso
Implement click listeners to handle item selection and display the selected image
You have been given a singly Linked List in the form of 'L1' -> 'L2' -> 'L3' -> ... 'Ln'. Your task is to rearrange the nodes of this list to make it in the form of 'L1' -> 'Ln' -> 'L2' -> ...read more
Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:
1. get(key) - Return the value of the key if the key exists in the cache, o...read more
You are given a string 'S', check if there exists any permutation of the given string that is a palindrome.
Note :
1. A palindrome is a word or phrase that reads the same from forward and ...read more
You had a sequence of consecutive nonnegative integers. You appended all integers at the end of each other to form a string ‘S’ without any separators. While appending each integer ...read more
Q6. You have to design screen in which at a time on screen 10 nearest restaurants will be shown in a list. The screen will keep adding more options while scrolling. Scroll in the list should be uninterrupted as pos...
read moreDesign a screen to show 10 nearest restaurants in a list with uninterrupted scrolling.
Use a RecyclerView to display the list of restaurants
Implement a custom adapter to populate the data in the list
Use a location service to get the user's current location
Sort the restaurants based on their distance from the user's location
Load more restaurants as the user scrolls to the end of the list
You are given an unsorted array containing ‘N’ integers. You need to find ‘K’ largest elements from the given array. Also, you need to return the elements in non-decreasing order.
Input Format:...read more
You are given a string of length N. You need to reverse the string word by word. There can be multiple spaces between two words and there can be leading or trailing spaces but in the ou...read more
You have been given an array 'ARR' of 'N' distinct elements.
Your task is to find the minimum no. of swaps required to sort the array.
For example:
For the given...read more
You are given the name of a student in the form of a character ‘firstLetterOfName’ and 3 integers ‘M1’, ‘M2’, ‘M3’ representing the marks of the student in 3 subjects. You have to print the ‘firstL...read more
You are given a Binary Search Tree (BST) and a target value ‘K’. Your task is to check if there exist two unique elements in the given BST such that their sum is equal to the given target ‘K’.
A...read more
Q12. You have application which shows list of all contacts, the Name/Numbers can be duplicated. How will you go on and do searching in this. Search term can either exist in Name or in Number.
To search for contacts with duplicate names or numbers, iterate through the list and compare each contact's name and number with the search term.
Iterate through the list of contacts
Compare the search term with each contact's name and number
Return the contacts that match the search term
You are given an 'N' * 'M' sized binary-valued matrix 'MAT, where 'N' is the number of rows and 'M' is the number of columns. You need to return the maximum size (a...read more
Given a rotated sorted array of size ‘N’ and let the elements of the given array be a1,a2,......,an . You need to sort the given array in increasing order.
For Example - Conside...read more
Design an photo viewing app which will show images from the disk in the list, and one item in the list should take half of the screen.
Q16. You have application which shows list of all contacts, the Name can be duplicated, also it can contain duplicated numbers (0XXXXX, XXXXX etc). How will you go on and do searching in this. Search term can either...
read moreTo search for contacts with duplicate names and numbers, create a search function that checks both fields.
Create a function that takes a search term as input
Iterate through the list of contacts
Check if the search term exists in the Name field or Num field
Return the contacts that match the search term
Q17. Java/Android : Given an Object 'Ball'. How will you transfer this ball object from one thread to another. Same ball object pass from Thread to MainThread.
To transfer the Ball object from one thread to another, we can use Handler or AsyncTask.
Use Handler to post a Runnable to the main thread's message queue
Use AsyncTask to perform background operations and update the UI on the main thread
Pass the Ball object as a parameter or use a shared variable between threads
You have been given a Binary Tree of 'N' nodes, where the nodes have integer values. Your task is to find the ln-Order, Pre-Order, and Post-Order traversals of the given binary tree.
For example...read more
You are given a string S which represents a number. You have to find the smallest number strictly greater than the given number which contains the same set of digits as of the original number...read more
Given an n x n matrix mat[n][n] of integers, find the maximum value of mat[c][d] – mat[a][b] over all choices of indexes such that both c > a and d > b.
Example:-
1 2 3 4 5 6 7 8 1 9 2 3 In th...read more
Given an array of ‘n’ integers arr. Find the Peak element of the array. The peak element of an array is defined as that element which is greater than both of its neighbours. I.e if arr[i] is th...read more
Ninja has been given two sorted integer arrays/lists ‘ARR1’ and ‘ARR2’ of size ‘M’ and ‘N’. Ninja has to merge these sorted arrays/lists into ‘ARR1’ as one sorted array. You may have ...read more
You have been given a sample of integers in the range [0, 255]. Since the sample is quite large, you are provided with an array/list “count” whose i-th element denotes the number o...read more
Q24. If you were asked to make your own HashMap, how will you do it. (As it was used in the first question)
To create my own HashMap, I would use an array of linked lists to handle collisions and implement key-value pairs using a hash function.
Create an array of linked lists to store the key-value pairs
Implement a hash function to generate an index for each key
Handle collisions by adding elements to the linked list at the corresponding index
Support operations like put(key, value), get(key), and remove(key)
You are given a binary tree having 'N' nodes. Each node of the tree has an integer value. Your task is to find the maximum possible sum of a simple path between any two nodes (...read more
You are given a binary tree with ‘N’ nodes.
Your task is to find the “Maximum Path Sum” for any path.
Note :
1. A ‘path’ is a sequence of adjacent pair nodes with an edge between the...read more
Given a string denoting a valid Prefix expression containing ‘+’, ’-’, ’*’, ‘/’ and uppercase letters. You are supposed to convert the given Prefix expression into an Infix expression.
Note:
An e...read more
You have been given a Binary Tree of integers. You are supposed to return the level order traversal of the given tree.
For example:
For the given binary tree
The level order traversal wil...read more
Q29. You have to design screen in which at a time on screen 10 nearest restaurants will be shown in a list. How will you go on design this. (Need to keep UI as un interrupted as possible).
Design a screen to show 10 nearest restaurants in a list while keeping the UI uninterrupted.
Use a scrollable list view to display the restaurants
Implement a location-based search algorithm to find the nearest restaurants
Include a search bar to allow users to search for specific restaurants
Display relevant information for each restaurant such as name, rating, and distance
Implement filters or sorting options to allow users to customize the list
Consider using a map view to show ...read more
You have a 2D grid of ‘N’ rows and ‘M’ columns which are initially filled with water. You are given ‘Q’ queries each consisting of two integers ‘X’ and ‘Y’ and in each query operation, you h...read more
You are given a string EXP which is a valid infix expression. Convert the given infix expression to postfix expression.
Infix expression is of the form a op b. Where operator is is between the ...read more
How to pass a simple Java object from one thread to another?
You have been given a perfect binary tree of 'N' nodes. Your task is to reverse alternate levels of the given binary tree. That is reverse level 2, level 4, level 6, and so on. The root i...read more
Q34. how does looper/handlers work internally when you pass object from one thread to another.
Looper/handlers allow passing objects between threads in Android.
Looper is a message loop that runs in a thread and processes messages from a message queue.
Handlers are used to send messages to the message queue of a looper.
When an object is passed from one thread to another using a handler, it is encapsulated in a message and added to the receiving thread's message queue.
The receiving thread's looper then processes the message and delivers it to the handler's callback method...read more
Design a weather app. (One image for every weather is there on a server) Take care of half downloaded image, try not to consume data of user again.
Q36. Given an array, which consist of natural numbers only. The elements are in random order, tell the first missing natural number in the array. e.g 4,6,3,1,6,8 o.p - 2 1,2,3 O/P - 4
Given an array of natural numbers, find the first missing natural number.
Sort the array and iterate through it to find the first missing number.
Use a hash set to keep track of the numbers present in the array.
The first missing number will be the smallest positive integer not present in the array.
You are given a stream of 'N' integers. For every 'i-th' integer added to the running list of integers, print the resulting median.
Print only the integer part of the median.
Input Format :
The fi...read more
Q38. Design a weather app. (One image for every weather is there on a server) Take care of half downloaded image, try not to consume data of user again.
A weather app that displays images for different weather conditions, taking care of half downloaded images and minimizing data consumption.
Implement image caching to store downloaded images locally
Check if the image is already downloaded before making a network request
Use a progress bar to indicate the download status of the image
Handle cases where the download is interrupted or incomplete
Implement a mechanism to resume the download from where it left off
Optimize image loadin...read more
Q39. Given an Object 'Ball'. How will you transfer this ball object from one thread to another in Android.
To transfer the Ball object from one thread to another in Android, we can use Handler or AsyncTask.
Use Handler to post the Ball object from one thread to another
Create a Handler in the receiving thread and use its post() method to receive the Ball object
Alternatively, use AsyncTask to perform the transfer in the background thread and update the UI thread with the Ball object
What are the different launch modes for activities?
What are the IPC mechanisms available in android OS?
Difference between deep links and app links?
Q43. What are the different android components and concepts such as Recycler View, View Model, ANR and how do they function internally?
Android components like Recycler View, View Model, ANR are essential for building robust Android applications.
Recycler View: Efficient way to display large data sets by recycling views as they scroll off the screen.
View Model: Manages UI-related data in a lifecycle-conscious way, surviving configuration changes.
ANR (Application Not Responding): Dialog shown to the user when the main thread of an app is blocked for too long.
Understanding how these components work internally is...read more
Design the ImageDownloader, with efficiently handling parallel API calls
Q46. Given a cartesian x-y plane and lot of points in that plane with x and y coordinates and 1 more point(say x,y) is given, so we have to find all the points in that plane which are lying in a radius of length r f...
read moreGiven a point and a radius, find all points in a cartesian plane within the radius.
Calculate the distance between the given point and all other points in the plane using the distance formula.
If the distance is less than or equal to the radius, add the point to the result set.
Return the result set of points within the radius of the given point.
Q48. Design the ImageDownloader, with efficiently handling parallel API calls.
ImageDownloader efficiently handles parallel API calls.
Use a thread pool to manage parallel API calls.
Implement caching to avoid redundant API calls.
Use a priority queue to prioritize image downloads.
Optimize network requests by using HTTP/2 or multiplexing.
Consider using a library like Picasso or Glide for image loading and caching.
Q49. How do you do DeepLinking in android.
Deep linking in Android allows users to navigate directly to specific content within an app.
Deep linking is achieved by defining intent filters in the app's manifest file.
The intent filter specifies the URL scheme and host that the app can handle.
When a deep link is clicked, Android checks if any app can handle the URL and prompts the user to choose.
The chosen app receives the deep link data in the intent's data field.
Deep linking can be used to open specific screens, perform...read more
What is an index? What kind of data structure is an index?
Q51. how you will find out 3rd smallest element from an array
To find the 3rd smallest element from an array, sort the array and return the element at index 2.
Sort the array in ascending order
Return the element at index 2
If the array has less than 3 elements, return null
Q52. Design a photo viewer app (Technical architecture) for android device.
A photo viewer app for Android devices.
Use RecyclerView to display a grid of photos
Implement a caching mechanism to improve performance
Support gestures for zooming and swiping between photos
Integrate with a cloud storage service for photo storage and retrieval
Implement a search feature to allow users to find specific photos
Why are synchronised blocks needed in Java?
How to analyze usage history of a application?
What is ConcurrentHashMap in Java?
Q56. What is STLC and how you work in different layers of it?
STLC stands for Software Testing Life Cycle. It is a process used to test software applications from planning to deployment.
STLC consists of phases like requirement analysis, test planning, test design, test execution, and test closure.
As a Senior Software Quality Engineer, I work in different layers of STLC by creating test plans, designing test cases, executing tests, and analyzing results.
I collaborate with developers, product managers, and other stakeholders to ensure hig...read more
Q57. What is Hr To manage business Hr basic rules? Processing, Planing, price
HR is the management of human resources to achieve business goals.
HR involves recruiting, training, and managing employees.
HR policies and procedures ensure compliance with laws and regulations.
HR also includes compensation and benefits management.
Effective HR planning can help organizations achieve their objectives.
HR analytics can provide insights into workforce trends and performance.
Q58. Designing a LRU Cache which is thread safe and can be scaled
Design a thread-safe LRU cache that can be scaled.
Use a ConcurrentHashMap to ensure thread safety.
Implement a doubly linked list to keep track of the least recently used items.
Use a HashMap to store the cache items for fast retrieval.
Implement a size limit for the cache and remove the least recently used item when the limit is reached.
To scale the cache, use a distributed cache like Redis or Memcached.
Q59. Write code to get maximum and second maximum element of a stack. The given function should be in O(1) complexity
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
Q60. Given a biotonic array ( first numbers increase and then decrease ) write code to search a given number. Time complexity O(logn)
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.
Producer Consumer problem using Semaphores
Q62. Launch Mode of Activity in Android
Launch mode determines how a new instance of an activity is created and added to the task stack.
Standard: Creates a new instance of the activity each time it is launched.
SingleTop: If an instance of the activity already exists at the top of the stack, it will be reused.
SingleTask: If an instance of the activity already exists in the stack, it will be brought to the front and cleared of any activities above it.
SingleInstance: The activity will be launched in a new task and no ...read more
Q63. How does Stack work internally and what data it holds?
Stack is a data structure that follows LIFO (Last In First Out) principle.
Stack holds a collection of elements
It has two main operations: push (adds element to top) and pop (removes element from top)
It also has peek operation (returns top element without removing it)
Stack can be implemented using arrays or linked lists
Examples: undo-redo functionality in text editors, back-forward navigation in web browsers
Design a file sharing mechanism between two users.
Q65. Launch Mode of Activity.
Launch mode determines how an activity is launched and how it behaves in the task stack.
Standard: Creates a new instance of the activity on each launch.
SingleTop: Reuses the existing instance if it's already at the top of the stack.
SingleTask: Creates a new task and places the activity at the root of the task.
SingleInstance: Creates a new task and places the activity as the only one in the task.
Q66. Experience on huge infrastructure, how to make decisions of scaling, performance and availability?
Scaling, performance, and availability decisions on huge infrastructure require a data-driven approach.
Analyze data on usage, traffic, and resource utilization to identify bottlenecks and areas for improvement.
Consider the impact of scaling on cost, user experience, and maintenance.
Implement monitoring and alerting systems to quickly identify and address issues.
Use load testing and performance profiling to optimize system performance.
Implement redundancy and failover mechanis...read more
Q67. do you know spell checker in micro soft word
Yes, spell checker is a built-in feature in Microsoft Word.
Spell checker automatically checks for spelling errors as you type.
It underlines misspelled words in red and suggests corrections.
You can also customize the spell checker settings and add words to the dictionary.
To access the spell checker, go to the Review tab and click on Spelling & Grammar.
Alternatively, you can use the shortcut key F7 to run the spell checker.
Q68. A sorted array is rotated K times. Sort it in o(n) traversal without extra space
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]
Characteristics of distributed file systems
Q70. Write the test cases regarding Facebook posts and set their priorities.
Test cases for Facebook posts with priorities
Verify that a user can create a new post
Check that a user can edit their own post
Ensure that a user can delete their own post
Test that a user can like a post
Verify that a user can comment on a post
Q71. Write the test cases to delete a node from a linked list
Test cases to delete a node from a linked list
Test deleting the first node in the linked list
Test deleting a node in the middle of the linked list
Test deleting the last node in the linked list
Test deleting a node that does not exist in the linked list
Q72. two pair with a given sum in a bst with o(log n) space
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)
Q73. K random numbers from infinite stream of array with equal probability
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
Q74. How to debug a full functionality of an API
Debugging a full functionality of an API involves thorough testing, logging, and using debugging tools.
Start by reviewing the API documentation to understand its functionality and expected behavior.
Write test cases to cover all possible scenarios and edge cases.
Use logging to track the flow of data and identify any issues.
Utilize debugging tools like Postman, Swagger, or browser developer tools to inspect API requests and responses.
Check for error messages and status codes to...read more
Q75. How to analyze usage history of a application
Usage history of an application can be analyzed by tracking user actions and behavior.
Collect data on user interactions with the application
Analyze the frequency and duration of usage
Identify patterns and trends in user behavior
Use data visualization tools to present findings
Consider user feedback and reviews for additional insights
Q76. How would you launch a new onboarding experience UI
I would launch a new onboarding experience UI by conducting user research, designing a user-friendly interface, testing with a small group, and gradually rolling out to all users.
Conduct user research to understand user needs and pain points
Design a user-friendly interface with clear instructions and intuitive navigation
Test the new onboarding experience with a small group of users to gather feedback and make improvements
Gradually roll out the new UI to all users while monito...read more
5 Pirates and 100 Gold Coins
Q78. Methods of IPC in android.
IPC (Inter-Process Communication) methods in Android allow communication between different processes.
Binder: Android's default IPC mechanism, provides high-performance communication between processes.
AIDL (Android Interface Definition Language): Used to define the programming interface for IPC using Binder.
Intents: Used for asynchronous communication between components within an application or between different applications.
Content Providers: Allow sharing data between applic...read more
Q79. Implement Inorder Traversal with and without using recursion
Inorder Traversal can be implemented using recursion or without recursion.
Inorder Traversal using recursion involves traversing the left subtree, visiting the root node, and then traversing the right subtree.
Inorder Traversal without recursion involves using a stack to keep track of the nodes to be visited.
For each node, push it onto the stack and traverse its left subtree until there are no more left nodes.
Pop the top node from the stack, visit it, and then traverse its righ...read more
Q80. Designing a file sharing mechanism between two users
Design a file sharing mechanism between two users
Use a secure protocol like HTTPS or SFTP
Implement access control to ensure only authorized users can access the files
Consider implementing encryption to protect the files during transit and at rest
Provide a user-friendly interface for uploading and downloading files
Implement version control to track changes made to the files
Consider implementing a notification system to alert users of new file uploads or changes
Q81. Write the Test Cases about Amazon Gift Card
Test cases for Amazon Gift Card
Verify that the gift card balance is correctly displayed
Test redeeming a gift card code
Check if multiple gift cards can be applied to a single purchase
Ensure that expired gift cards are not accepted
Test the functionality of sending a gift card to someone else
Q82. Reverse alternate levels of a binary tree
Reverse alternate levels of a binary tree
Traverse the tree level by level
Reverse the nodes of alternate levels
Use a queue or stack to keep track of nodes at each level
Recursively apply the same process to the children of reversed nodes
Q83. Implement an LRU cache
LRU cache is a data structure that stores the most recently used items, discarding the least recently used items when full.
Use a hashmap to store key-value pairs for quick access
Use a doubly linked list to keep track of the order of items based on their usage
When an item is accessed, move it to the front of the list
When the cache is full, remove the least recently used item from the end of the list
Q84. Why manhole is round ?
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
Q85. Explain the architecture of transformer models.
Q86. Median of a stream of array
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
Q87. 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
Q88. Sell a water bottle
Stay hydrated on the go with our durable and stylish water bottle.
Highlight the durability of the water bottle
Emphasize the convenience of staying hydrated while on the go
Mention the stylish design to appeal to fashion-conscious customers
Q89. Sell a laptop cover
Protect your laptop in style with our sleek and durable laptop cover.
Made from high-quality materials to ensure maximum protection
Available in various sizes to fit different laptop models
Stylish designs to suit your personal taste
Easy to clean and maintain for long-lasting use
Top HR Questions asked in null
Interview Process at null
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month