๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.7K 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 <bits/stdc++.h>
using namespace std;

int main ()
{
  int n; cin >> n;
  vector<int> b(n), a;
  for (auto & x : b) cin >> x;

  int X; cin >> X;
  for (int i = 0; i < X; i++) {
    vector<int> newb(n);
    for (int i = 0; i < n; i++) {
      newb[i] = abs(b[i] - b[(i+1)%n]);
    }
    a = b;
    b = newb;   
  }
  cout << "A: ";
  for (auto x : a) cout << x << " ";
  cout << endl;
  cout << "B: ";
  for (auto x : b) cout << x << " ";
  cout << endl;
}


Micron โœ…
SinglyLinkedListNode* findLongestList(SinglyLinkedListNode* head) {
    if (!head) return nullptr;

    SinglyLinkedListNode* curr = head;
    SinglyLinkedListNode* start = head;
    SinglyLinkedListNode* bestStart = head;

    int length = 1;
    int bestLength = 1;

    while (curr->next) {
        if (curr->data >= curr->next->data) {
            length++;
        } else {
            if (length > bestLength) {
                bestLength = length;
                bestStart = start;
            }
            length = 1;
            start = curr->next;
        }
        curr = curr->next;
    }
    if (length > bestLength) {
        bestLength = length;
        bestStart = start;
    }
    SinglyLinkedListNode* temp = bestStart;
    for (int i = 1; i < bestLength && temp; i++) {
        temp = temp->next;
    }
    if (temp) {
        temp->next = nullptr;
    }

    return bestStart;
}

Amazon OA| AWS Databased
C++โœ…
long findTotalExecutionTime(vector<int>& execution) {
    int n = execution.size();
    vector<int> original = execution;
    long totalTime = 0;
    unordered_map<int, list<int>> origIndicesMap;

    for (int i = 0; i < n; i++) {
        origIndicesMap[original[i]].push_back(i);
    }

    for (int i = 0; i < n; i++) {
        totalTime += execution[i];

        if (origIndicesMap[original[i]].size() > 1) {
            int reducedValue = ceil((double)execution[i] / 2);
            for (int idx : origIndicesMap[original[i]]) {
                if (idx != i) {
                    execution[idx] = reducedValue;
                }
            }
        }
    }

    return totalTime;
}

Amazon
C++ โœ