allcoding1
27.7K subscribers
2.2K photos
2 videos
74 files
851 links
Download Telegram
MOD = 10**9 + 7

def solve(arrival_departure):
    arrival_departure.sort(key=lambda x: x[1])
    prev_departure = -1
    total_stations = 0

    for arrival, departure in arrival_departure:
        if arrival > prev_departure:
            total_stations += 1
            prev_departure = departure

    return total_stations % MOD

def main():
    N = int(input())
    arrival_departure = []
    for _ in range(N):
        arrival, departure = map(int, input().split())
        arrival_departure.append((arrival, departure))
   
    result = solve(arrival_departure)
    print(result)

if name == "main":
    main()

Trains Code
Python

HackWithInfy

Telegram:- @allcoding1
👍2
Forwarded from allcoding1
📌IT learning courses
📌All programing courses
📌Abdul bari courses
📌Ashok IT

100 rupees

Contact:- @meterials_available
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int getSmallestArea(vector<vector<int>>& grid) {
    int rows = grid.size();
    if (rows == 0) return 0;
    int cols = grid[0].size();
    if (cols == 0) return 0;

    set<int> rowsSet, colsSet;

    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            if (grid[i][j] == 1) {
                rowsSet.insert(i);
                colsSet.insert(j);
            }
        }
    }

    int width = colsSet.empty() ? 0 : *colsSet.rbegin() - *colsSet.begin() + 1;
    int height = rowsSet.empty() ? 0 : *rowsSet.rbegin() - *rowsSet.begin() + 1;

    return width * height;


shipping space
Salesforce

Telegram:- @allcoding1
👏1
import heapq
def reduce_sum(lst):
    heapq.heapify(lst)
    s = 0
    while len(lst) > 1:
        first = heapq.heappop(lst)
        second = heapq.heappop(lst)
        s += first + second
        heapq.heappush(lst, first + second)
    return s

Reduce the Array
Salesforce

Telegram:- @allcoding1
#include <iostream>
#include <vector>
#include <algorithm>

int getPotentialOfWinner(std::vector<int>& potential, long long k) {
    int n = potential.size();

    int x = potential[0];
    int m = 0;
    for (int i = 1; i < n; i++) {
        if (m != k) {
            if (x > potential[i]) {
                m++;
            } else {
                x = potential[i];
                m = 1;
            }
        }
    }

    return x;
}

int main() {
    std::vector<int> potentials = {3, 2, 1, 4};
    long long k = 2;
    std::cout << getPotentialOfWinner(potentials, k) << std::endl;
    return 0;
}

Potential winner code

Telegram:- @allcoding1
👍2
int minimumKeypresses(string s) {
        unordered_map<char, int> counts;
        for (char ch : s) {
            counts[ch]++;
        }

        vector<int> frequencies;
        for (const auto& kvp : counts) {
            frequencies.push_back(kvp.second);
        }

        sort(frequencies.begin(), frequencies.end(), greater<int>());

        vector<int> remain {9, 9, 9};
        int i = 0, total = 0;
        for (int count : frequencies) {
            total += count * (i + 1);
            remain[i]--;
            if (remain[i] == 0) {
                i++;
            }
        }
       
        return total;
    }

Amazon

Telegram:- @allcoding1
1👍1
def processExecution(power, minPower, maxPower):
    result = []
    for min_p, max_p in zip(minPower, maxPower):
        count = sum(1 for p in power if min_p <= p <= max_p)
        power_sum = sum(p for p in power if min_p <= p <= max_p)
        result.append((count, power_sum))
    return result

Amazon

Telegram:- @allcoding1
3👍1
TCS FREE NQT - Biggest Mass Hiring

Graduation Year: 2024

Eligibility: BTech / BE / MTech / ME / MCA / MSc / MS

Experience: Freshers

Salary:
Ninja - 3.36 LPA
Digital - 7 LPA
Prime - 9 LPA for UG and 11.5 LPA for PG

Apply now:-  www.allcoding1.com


Registration End Date: 10 April 2024
Test Date: 26th April Onwards

Telegram:- @allcoding1
👍4
🎯Indian Army recruitment for Engineers - male unmarried and below 27 years of age.

Batch : 2024, 2023, 2022 and previous passout batches.

Position : Lieutenant ( Pay Range : 56k-1.77L)

Apply Now:-
https://www.allcoding1.com/2024/04/indian-army.html
👍3