Saturday, 4 Dec 2021

#include using namespace std;  void solve(long long int r, long long int c,           vector& grid){    priority_queue        pq;      for (long long int i = 0; i < r; i++) {        for (long long int j = 0; j < c; j++) {            pq.push(make_pair(grid[i][j],                              make_pair(i, j)));        }    }      long long int res = 0;      while (!pq.empty()) {        long long int height = pq.top().first,                      i = pq.top().second.first,                      j = pq.top().second.second;        pq.pop();        if (height != grid[i][j])            continue;        if […]

Pretty much sure, getting a job in the tech giant Google is on the bucket list of a majority of the tech individuals whether it be a fresher or an experienced working professional. And why not, as those ravishing salary packages, utmost learning exposure, better career opportunities, wonderful perks, etc. offered by Google to its […]

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

Given a 2D array, arr of size N*N where arr[i][j] denotes the cost to complete the jthjob by the ith worker. Any worker can be assigned to perform any job. The task is to assign the jobs such that exactly one worker can perform exactly one job in such a way that the total cost […]

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

import java.util.*;  class GFG {                  static void findMinimumTime(        String tasks, int K)    {                        Map map            = new HashMap();                  int curr_time = 0;                  for (char c : tasks.toCharArray()) {                                      if (map.containsKey(c)) {                                                                  if (curr_time                        – map.get(c)

import java.util.*;  class GFG {                  static void findMinimumTime(        String tasks, int K)    {                        Map map            = new HashMap();                  int curr_time = 0;                  for (char c : tasks.toCharArray()) {                                      if (map.containsKey(c)) {                                                                  if (curr_time                        – map.get(c)

import java.util.*;  class GFG {              public static int MaxCollection(        String S, int P, int Q)    {                        char maxstr[]            = (P >= Q ? “ab” : “ba”).toCharArray();                          char minstr[]            = (P >= Q ? “ba” : “ab”).toCharArray();                  int maxp = Math.max(P, Q);                  int minp = Math.min(P, Q);                  int cost = 0;                                    Stack stack1 = new Stack();        char[] s = S.toCharArray();                  for (char ch : s) {                            if (!stack1.isEmpty()                && (stack1.peek() == maxstr                    && […]

Google Interview Experience for Software Engineer (November 2020)Note: All rounds were virtual.Phone Screen Round:Implement a doubly-linked list, with all edge cases considered.Onsite Rounds:Round 1: Add (Key, value) pairs of two lists which are representing different values at different time stamps. HINT: USE Interpolation and Extrapolation, to find the values of the missing time stamp.Round 2: The question […]

import java.util.*;    class Node {        int val;     Node next;             Node(int val)     {         this.val = val;         this.next = null;     } }    class GFG {             public static void mergeSheets(         Node lists[])     {                  PriorityQueue pq                = new PriorityQueue(                 new Comparator() {                                                                  public int compare(Node a, […]