Monday, 29 Nov 2021
Category: Probability

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 = 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 […]

Given two positive integers N and S, the task is to count the number of unique outcomes possible when S flip operations are performed on N coins. Examples: Input: N = 3, S = 4Output: 3Explanation: Considering the intiial configuration of coins to be “HHH”, then the possible combinations of 4 flips are: Flipping the […]