# interview-preparation

### Maximum number of teams of size K possible with each player from different country

Given an array arr[] consisting of N positive integers and a  positive integer K such that there are N countries,…

### TCS CodeVita 9 ( Zone 1) 2020 | Constellation

#include using namespace std;  void printGalaxy(    vector mat, int n){          for (int i = 0; i < n; i++) {                          if (mat[0][i] == '#'            &&…

### Find instances at end of time frame after auto scaling

Given an integer, instances, and an array, arr[] of size N representing the average utilization percentage of the computing system…

### Design a dynamic stack using arrays that supports getMin() in O(1) time and O(1) extra space

#include using namespace std;  class Stack {private:            int Max = 5;              int* arr = new int(Max);              int minEle = 0;              int top = 0;  public:            bool empty()    {        if…

### Probability of obtaining pairs from two arrays such that element from the first array is smaller than that of the second array

import java.util.*;  class GFG {                  static double probability(int[] arr1,                              int[] arr2)    {                int N = arr1.length;                  int M = arr2.length;                  double res = 0;                          Arrays.sort(arr2);                  for (int i =…

### Minimum sprinkers required to be turned on to water the plants

Given an array arr[] consisting of N integers, where the ith element represents the range of a sprinkler i.e [i-arr[i],…

### Subtract 1 from a number represented as Linked List

#include using namespace std;  class Node {public:    int data;    Node* next;};  Node* newNode(int data){        Node* new_node = new Node;    new_node->data = data;    new_node->next = NULL;          return new_node;}  int subtractOneUtil(Node*…

### Minimum time required to schedule K processes

import java.util.*;import java.lang.*;  class GFG {              static int minTime(int[] A, int n, int K)    {                int max_ability = A[0];                  for (int i = 1; i…