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

# Mathematical

### 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;…

### 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…

### 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,…

### Minimize value of |A – X| + |B – Y| + |C – Z| such that X * Y = Z

Given three integers A, B, and C, the task is to find the minimum possible value of |A – X|…

### Check if count of 1s can be made greater in a Binary string by changing 0s adjacent to 1s

Given a binary string S of size N, the task is to check if the count of 1s can be…

### Minimize operations to make all array elements -1 by changing maximums of K-size subarray to -1

Given an array arr[] consisting of N integers and an integer K, the task is to find the minimum of…

### K-th smallest positive integer having sum with given number equal to bitwise OR with given number

Given two positive integers X and K, the task is to find the K-th smallest positive integer Y, such that…

### Lexicographically smallest binary string formed by flipping bits at indices not divisible K1 or K2 such that count of 1s is always greater than 0s from left

#include using namespace std; void generateString(int k1, int k2, string s){ int C1s = 0, C0s = 0; int flag = 0; vector pos; for…