Given an array arr[] consisting of N positive integers and a positive integer K such that there are N countries, each country has arr[i] players, the task is to find the maximum number of teams that can be formed by forming teams of size K such that each player in the team is from a […]

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

Continue ReadingGiven an integer, instances, and an array, arr[] of size N representing the average utilization percentage of the computing system at each second, the task is to find the number of instances at the end of the time frame such that the computing system auto-scales the number of instances according to the following rules: Average utilization […]

Continue Reading#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 (top

Continue Readingimport 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 = 0; i < N; i++) { int y = countGreater( arr2, arr1[i]); res += y; } res = (double)res / (double)(N * M); return res; } static int countGreater(int[] arr, int k) { int n = arr.length; int l = 0; int r = n - 1; int leftGreater […]

Continue ReadingGiven an array arr[] consisting of N integers, where the ith element represents the range of a sprinkler i.e [i-arr[i], i+arr[i]] it can water, the task is to find the minimum number of the sprinkler to be turned on to water every plant at the gallery. If it is not possible to water every plant, […]

Continue Reading#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* head){ if (head == NULL) return -1; int borrow = subtractOneUtil( head->next); if (borrow == -1) { if (head->data == 0) { head->data = 9; return -1; } else { head->data = head->data – 1; return 0; } } else { return 0; }} Node* subtractOne(Node* head){ subtractOneUtil(head); while (head and head->next and head->data == 0) […]

Continue Readingimport 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 < n; i++) { max_ability = Math.max( max_ability, A[i]); } int tmp[] = new int[max_ability + 1]; int count = 0; for (int i = 0; i < n; i++) { tmp[A[i]]++; } for (int i = max_ability; i >= 0; i–) { if (tmp[i] != […]

Continue ReadingWithout Doubt Assistance: The price of the self-paced online DSA course without doubt assistance is INR 2,499. Click here to purchase your ticket .Preparing for AMAZON SDE Interview?Do check out Geeksforgeeks Amazon SDE Test-Series. The price of the online AMAZON Test-Series course is INR 499. Geeks Classes LiveAn interview centric Live session focused on DSA […]

Continue ReadingMinimum time required to complete all tasks with alteration of their order allowedGiven a string S consisting of N characters (representing the tasks to perform) and a positive integer K, the task is to find the minimum time required to complete all the given tasks in any order, given that each task takes one unit […]

Continue Reading