Minimum time difference Given a list of 24-hour clock time points in “HH:MM” format. Write a program to find the minimum minutes difference between any two time-points in the list. Example: Given hours: [00:00, 03:00, 22:30] minimum time difference: 90 Given hours: [01:59, 03:00, 21:50, 22:30] minimum time difference: 40 Solution: Convert all the given … Read more Minimum time difference
You are on a business trip and traveling from one city to another. you have a stack of unsorted flight boarding passes. The only departure city and destination city are on the boarding pass. how do you find the first departure city and your final destination city, Example: [Dallas, Austin], [Houston, Dallas], [Austin, Seattle] Output: … Read more Find departure and destination cities from the itinerary
Given an array of numbers, write a program to rank the array elements. Example: Given array: [22, 11, 44, 66, 55] Rank: [2, 1, 3, 5, 4] Given array: [15, 12, 11, 10, 9] Rank: [5, 4, 3, 2, 1] Given array: [10, 20, 30, 40, 50] Rank: [1, 2, 3, 4, 5] Given array: … Read more Rank Array Elements
The “surpasser” of an element in an array is defined as the number of elements that are to the “right” and bigger than itself. Write an algorithm to Find the maximum surpasser of the array. Example: Input array: [2, 7, 5, 5, 2, 7, 0, 8, 1] The “surpassers” are [5, 1, 2, 2, 2, … Read more Maximum Surpasser in the given array
Given a list of n Jobs with start time, end time and CPU load when it is active at any moment. If all the jobs are running at the same machine then find the maximum CPU load at any time, Also print the time at which the load was maximum. Input: Given a list of … Read more Maximum CPU Load Problem
In school a student gets rewarded if he has an attendance record without being absent for more than once or being late for 3 times continuously. Given a student’s attendance record represented by a string. The record only contains the following three characters: ‘A’ : Absent. ‘L’ : Late. ‘O’ : On-Time. Check whether the … Read more Student Attendance Reward
Interval is defined as [start, end]- the start of the interval to the end of the interval. Given the list of Intervals write an algorithm to find the maximum number of intervals overlapping at any point in time. Example: Given Intervals: [[0,2], [3,7], [1,5], [7,8], [4,6]] Maximum overlapping: 3 Explanation: Interval (4, 5) is overlapping … Read more Count Maximum overlaps in a given list of time intervals
Given a bench with n seats and few people sitting, You are going to sit on a vacant seat such that the distance between you and the nearest person to you is maximum. On the beach, the occupied seats are represented by 1 and vacant seats are represented by 0. Example: Input: [1, 0, 1, … Read more Maximum distance from the nearest person.
Given candidates standing for an election, design a data structure that can support the following modules – 1. voteCandidate (candidateName) – Add one vote for the candidate. 2. getTopK ( k ) – This will return top K candidates at that time. It can return more than k candidates if more candidates have the same … Read more Candidate Voting Problem
Given a list of player names and their scores, design a data structure that can support following modules in optimal time- updateEntry(String name) – Increase the player score with “name” by 1. If no player with name is present then add a player with score 1. getEntryFromRank(int rank) – Get the players with the given … Read more Design data structure for players and ranks
Problem: Given a bipartite graph, write an algorithm to find the maximum matching. The maximum bipartite matching solves many problems in the real world like if there are M jobs and N applicants. Each applicant can do some jobs. Your task is to assign these jobs to the applicants so that maximum applicants get the … Read more Maximum Bipartite Matching Problem
Given a list L of video names and their watch rates, write a function that will return the videos with the top 10 watch rates. Video names may appear more than once. Example: Input: [abc : 10] [def : 20] [abc : 15] [ghi : 50] [xyz : 100] [abc : 25] [jkl : 10] … Read more Print Top 10 videos from List
Given two versions of a software, write an algorithm to find out which version is the latest. Example: Version A: 1.1.0 Version B: 1.1.1 Given version B latest than version A Version A: 1.2.1 Version B: 1.2.1 Given versions are the same Version A: 2.2.0 Version B: 2.2 Given versions are the same Version A: … Read more Compare two version numbers of a software
Given a string A consisting of n characters and a string B consisting of m characters, write a function that will return the number of times A must be stated such that B is a substring of the repeated A. If B can never be a substring, return -1. Example: A = ‘abcd’ B =’cdabcdab’ … Read more Minimum number of times String A is repeated to such that B is substring of A
Objective: Given an array of size N which contains integers from range 0 to N-1. (No duplicates). Write a program to find the number of cycles in the array. Cycles in Array: Since the array is of size N and elements are from 0 to N-1 without any duplicates means all the elements appear exactly … Read more The number of cycles in a given array of integers.