# Blogathon

### Queue Operations

using System;using System.Collections.Generic;public class GFG {     public class Geeks {           public void insert(Queue q, int k)    {                q.Enqueue(k);    }            public int findFrequency(Queue q, int k)    {                int cntFrequency…

### Check if given array can be rearranged such that mean is equal to median

#include using namespace std;bool binarySearch(float arr[], int size, float key){    int low = 0, high = size – 1, mid;    while (low…

### Sum of the shortest distance between all 0s to 1 in given binary string

#include using namespace std;void findTotalDistance(string S, int N){            vector prefixDistance(N);    vector suffixDistance(N);            int cnt = 0;        bool haveOne = false;    for (int i = 0;…

### Print all ways to reach the Nth stair with the jump of 1 or 2 units at a time

Given a positive integer N representing N stairs and a person it at the first stair, the task is to…

### Count of distinct integers belonging to first N terms of at least one of given GPs

Given two Geometric Progressions (a1, r1) and (a2, r2) where (x, y) represents GP with initial term x and common…

### Maximum element in connected component of given node for Q queries

#include using namespace std;  int Find(vector& parent, int a){    return parent[a] = (parent[a] == a)                           ? a                           : (Find(parent, parent[a]));}  void Union(vector& parent,           vector& rank,           vector& maxValue,           int…

### Implementation of Johnson’s algorithm for all-pairs shortest paths

import java.util.ArrayList;import java.util.Arrays;  public class Graph {    private static class Neighbour {        int destination;        int weight;          Neighbour(int destination, int weight)        {            this.destination = destination;            this.weight = weight;        }    }      private int…

### Form a Rectangle from boundary elements of Matrix using Linked List

class Node:          def __init__(self, val):        self.data = val        self.next = None        self.prev = None        self.top = None        self.bottom = None    class LinkedList:          def __init__(self):        self.head = None              def Quad(self, grid,…