๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.59K subscribers
5.59K photos
3 videos
95 files
10.1K 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
Company Name: RagaAI

Roles:
1) SDE 1 (1-2 years of experience)
2) SDE Intern (2024 and 2025 grads)

๐Ÿ“ฉHow to Apply:
Please send your resume to my inbox or email me at gaurav007jha@gmail.com. Mention "SDE1 Application" or "SDE Intern Application" in your message.
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int countCoins(int N, int Target, int Max_coins) {
    vector<vector<int>> dp(N + 1, vector<int>(Max_coins + 1, 0));

    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= Max_coins; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j >= i && i != Target + 1) {  // Exclude the target island from contributing to the count
                dp[i][j] = max(dp[i][j], dp[i - 1][j - i] + 1);
            }
        }
    }

    return dp[N][Max_coins];
}
๐Ÿ‘1
function findShortestPath(N, bricks) {
  let visited = new Set();
  let queue = [[0, 0]];

  while (queue.length > 0) {
    let [position, moves] = queue.shift();

    if (position === N - 1) {
      return moves;
    }

    visited.add(position);
    if (position + 1 < N && bricks[position] === bricks[position + 1] && !visited.has(position + 1)) {
      queue.push([position + 1, moves + 1]);
    }

    if (position - 1 >= 0 && bricks[position] === bricks[position - 1] && !visited.has(position - 1)) {
      queue.push([position - 1, moves + 1]);
    }

    for (let i = 0; i < N; i++) {
      if (bricks[i] === bricks[position] && !visited.has(i)) {
        queue.push([i, moves + 1]);
      }
    }
  }
  return -1;
}

Dorothy has been caught up
process.stdin.on('data', data => {
  inputArr.push(data.toString().trim());
  if (++count === 3) {
    console.log(divideMutantsIntoTeams(inputArr));
    process.exit(0);
  }
});

function divideMutantsIntoTeams(inputArr){
  let N = parseInt(inputArr[0], 10);
  let K = parseInt(inputArr[1], 10);
  let mutants = inputArr[2].split(' ').map(Number);


  if (N < K || new Set(mutants).size === 1 || N % K !== 0) {
    return -1;
  }


  mutants.sort((a, b) => a - b);
  let minNonCompatibilityScore = Infinity;

  for (let i = 0; i <= N - K; i++) {
    let diff = mutants[i + K - 1] - mutants[i];
    if (diff < minNonCompatibilityScore) {
      minNonCompatibilityScore = diff;
    }
  }

  return minNonCompatibilityScore;
}

Xaviers Fight with magento
var stdin process.openStdin();
stdin.addListener("data", function(d) {

// note: d is an object, and when converted to a string it will
// end with a linefeed. so we (rather crudely) account for that
// with toString() and then trim()
console.log(d.toString().trim());

});


Driver Code โœ