There are n jobs to be processed on a machine. Each job i has a deadline and a profit. Profit is earned if the job is completed by its deadline. Job is completed if it is processed on a machine for unit time.
A message containing letters from A-Z can be encoded into numbers. To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping
Greedy approach and Dynamic programming both are used for solving optimisation problems. However often we need to use DP since optimal solution cannot be guaranteed by a greedy algorithm.
The number of possible partition of a set of n elements is B(n) known as Bell number. As we know, this problem is NP-Complete i.e. it has non-polynomial time solution.
While it is given that if two numbers are same in the given set, they have different colors. It means that if a1 = a2, then choosing a1 and choosing a2 will be considered as different sets.
Quick Sort is capable of sorting a list of data elements significantly faster (twice or thrice faster) than any of the common sorting algorithms and that’s why it is the favourite topic of interviewers.
You are given an m x n binary matrix grid. An island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.