๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.67K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int maxMinDistance(vector<int>& x, int k) {
    sort(x.begin(), x.end());
    int low = 0, high = x.back() - x.front();
    int result = 0;

    while (low <= high) {
        int mid = (low + high) / 2;
        int count = 1;
        int lastPoint = x[0];

        for (int point : x) {
            if (point - lastPoint >= mid) {
                count++;
                lastPoint = point;
            }
        }

        if (count >= k) {
            result = mid;
            low = mid + 1;
        } else {
            high = mid - 1;
        }
    }

    return result;
}

//Optimal points selection โœ