#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef vector<vector<long long>> Matrix;
Matrix multiply(const Matrix &A, const Matrix &B) {
int n = A.size();
Matrix result(n, vector<long long>(n, 0));
for (int i = 0; i < n; ++i) {
for (int k = 0; k < n; ++k) {
if (A[i][k]) {
for (int j = 0; j < n; ++j) {
result[i][j] = (result[i][j] + A[i][k] * B[k][j]) % MOD;
}
}
}
}
return result;
}
Matrix matrix_power(Matrix base, long long exponent) {
int n = base.size();
Matrix result(n, vector<long long>(n, 0));
for (int i = 0; i < n; ++i)
result[i][i] = 1;
while (exponent > 0) {
if (exponent % 2 == 1)
result = multiply(result, base);
base = multiply(base, base);
exponent /= 1LL << 1;
}
return result;
}
int solve(long long A, int B, int C) {
if (A == 0)
return 0;
vector<long long> S0(B, 0);
S0[0] = C % MOD;
Matrix M(B, vector<long long>(B, 0));
for (int k = 0; k < B; ++k) {
if (k + 1 < B) {
M[k][k + 1] = 1;
}
M[k][0] = (C - 1) % MOD;
}
Matrix M_power = matrix_power(M, A - 1);
vector<long long> S(B, 0);
for (int i = 0; i < B; ++i) {
for (int j = 0; j < B; ++j) {
S[i] = (S[i] + S0[j] * M_power[j][i]) % MOD;
}
}
long long total = 0;
for (int i = 0; i < B; ++i) {
total = (total + S[i]) % MOD;
}
return (int)total;
}
Valid Array (Trilogy) โ
using namespace std;
const int MOD = 1e9 + 7;
typedef vector<vector<long long>> Matrix;
Matrix multiply(const Matrix &A, const Matrix &B) {
int n = A.size();
Matrix result(n, vector<long long>(n, 0));
for (int i = 0; i < n; ++i) {
for (int k = 0; k < n; ++k) {
if (A[i][k]) {
for (int j = 0; j < n; ++j) {
result[i][j] = (result[i][j] + A[i][k] * B[k][j]) % MOD;
}
}
}
}
return result;
}
Matrix matrix_power(Matrix base, long long exponent) {
int n = base.size();
Matrix result(n, vector<long long>(n, 0));
for (int i = 0; i < n; ++i)
result[i][i] = 1;
while (exponent > 0) {
if (exponent % 2 == 1)
result = multiply(result, base);
base = multiply(base, base);
exponent /= 1LL << 1;
}
return result;
}
int solve(long long A, int B, int C) {
if (A == 0)
return 0;
vector<long long> S0(B, 0);
S0[0] = C % MOD;
Matrix M(B, vector<long long>(B, 0));
for (int k = 0; k < B; ++k) {
if (k + 1 < B) {
M[k][k + 1] = 1;
}
M[k][0] = (C - 1) % MOD;
}
Matrix M_power = matrix_power(M, A - 1);
vector<long long> S(B, 0);
for (int i = 0; i < B; ++i) {
for (int j = 0; j < B; ++j) {
S[i] = (S[i] + S0[j] * M_power[j][i]) % MOD;
}
}
long long total = 0;
for (int i = 0; i < B; ++i) {
total = (total + S[i]) % MOD;
}
return (int)total;
}
Valid Array (Trilogy) โ
Don't apply for jobs at Workday and
Prefer applying for jobs at platforms like greenhouse, LinkedIn, lever, indeed or Glassdoor.
Your job application process should scale easily and one application shouldn't take more than 2 min to apply.
Workday sucks at scalability, Better to ignore it.๐
Prefer applying for jobs at platforms like greenhouse, LinkedIn, lever, indeed or Glassdoor.
Your job application process should scale easily and one application shouldn't take more than 2 min to apply.
Workday sucks at scalability, Better to ignore it.๐
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐ Exciting Internship Opportunity at T-Systems! ๐
Are you a 2024 graduate looking to kickstart your career with hands-on industry experience? ๐ T-Systems is hiring interns for various exciting roles.
โ Who can apply?
Graduates with 60% or more throughout their 10th, 12th, Graduation/Post Graduation.
Degree in BCS, BSc, MSc, MCA, BE, BTech, or MBA.
Passout year: 2024 only
๐ Locations: Pune or Bangalore
๐ Internship Duration: 3-6 months
Apply here: https://smrtr.io/nvkHg
Are you a 2024 graduate looking to kickstart your career with hands-on industry experience? ๐ T-Systems is hiring interns for various exciting roles.
โ Who can apply?
Graduates with 60% or more throughout their 10th, 12th, Graduation/Post Graduation.
Degree in BCS, BSc, MSc, MCA, BE, BTech, or MBA.
Passout year: 2024 only
๐ Locations: Pune or Bangalore
๐ Internship Duration: 3-6 months
Apply here: https://smrtr.io/nvkHg
Smartrecruiters
T-Systems ICT India Pvt. Ltd. Intern | SmartRecruiters
Internship for 2024 pass out Candidates Duration of 3- 6 months
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
https://boards.greenhouse.io/thetradedesk/jobs/4435073007?gh_src=1c01b2067us&source=LinkedIn
2025 and 2026 are eligible
2025 and 2026 are eligible
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int K = sc.nextInt();
int N = sc.nextInt();
int[] commands = new int[N];
for (int i = 0; i < N; i++) {
commands[i] = sc.nextInt();
}
int[] dx = {0, 1, 0, -1};
int[] dy = {1, 0, -1, 0};
int x = 0, y = 0;
int dir = 0;
int totalX = 0, totalY = 0;
for (int i = 0; i < N; i++) {
x += commands[i] * dx[dir];
y += commands[i] * dy[dir];
dir = (dir + 1) % 4;
}
totalX = x;
totalY = y;
int finalX = totalX * K;
int finalY = totalY * K;
System.out.println(Math.abs(finalX) + Math.abs(finalY));
sc.close();
}
}
Autonomous Car AIโ
Intuit
Forwarded from Juspay | IBM | Accenture | TCS | Wipro | Cognizant | Capgemini | Amazon | Exam Group | Discussion Group - SuperExams (Dushyant)
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
char[] colors = {'R', 'O', 'Y', 'G', 'B', 'I', 'V'};
Set<Character> usedColors = new HashSet<>();
for (int i = 0; i < N; i++) {
int canNumber = sc.nextInt();
char color = colors[(canNumber - 1) % 7];
usedColors.add(color);
}
System.out.println(usedColors.size());
sc.close();
}
}
Colors of the Rainbow โ
Intuit
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
https://boards.greenhouse.io/thetradedesk/jobs/4435073007?gh_src=1c01b2067us&source=LinkedIn
2025 and 2026 are eligible
2025 and 2026 are eligible
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
int findMinSum(const vector<int>& arr, int z, int k) {
int n = arr.size();
int minSum = k + 1;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int a = 0; a <= k; ++a) {
int rem = z - a * arr[i];
if (rem < 0) break;
if (rem % arr[j] == 0) {
int b = rem / arr[j];
if (a + b <= k) {
minSum = min(minSum, a + b);
}
}
}
}
}
return (minSum <= k) ? minSum : -1;
}
vector<int> solve(const vector<int>& arr, const vector<int>& query, int k) {
vector<int> result;
for (int z : query) {
int minSum = findMinSum(arr, z, k);
result.push_back(minSum);
}
return result;
}
Solving linear Equationโ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX;
vector<ll> dijkstra(int n, int src, const vector<vector<pair<int, int>>>& adj) {
vector<ll> dist(n, INF);
dist[src] = 0;
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> pq;
pq.push({0, src});
while (!pq.empty()) {
auto [d, u] = pq.top();
pq.pop();
if (d > dist[u]) continue;
for (auto [v, cost] : adj[u]) {
if (dist[u] + cost < dist[v]) {
dist[v] = dist[u] + cost;
pq.push({dist[v], v});
}
}
}
return dist;
}
vector<vector<ll>> shortest(int nodes, const vector<int>& deliveries, const vector<vector<pair<int, int>>>& adj) {
int k = deliveries.size();
vector<vector<ll>> dist(k, vector<ll>(nodes));
for (int i = 0; i < k; ++i) {
dist[i] = dijkstra(nodes, deliveries[i], adj);
}
return dist;
}
ll minTime(int nodes, int k, const vector<ll>& startDist, const vector<vector<ll>>& dist, const vector<int>& deliveries) {
vector<vector<ll>> dp(1 << k, vector<ll>(k, INF));
for (int i = 0; i < k; ++i) {
dp[1 << i][i] = startDist[deliveries[i]];
}
for (int mask = 0; mask < (1 << k); ++mask) {
for (int i = 0; i < k; ++i) {
if (mask & (1 << i)) {
for (int j = 0; j < k; ++j) {
if (!(mask & (1 << j))) {
dp[mask | (1 << j)][j] = min(dp[mask | (1 << j)][j], dp[mask][i] + dist[i][deliveries[j]]);
}
}
}
}
}
ll minTime = INF;
for (int i = 0; i < k; ++i) {
minTime = min(minTime, dp[(1 << k) - 1][i] + dist[i][0]);
}
return minTime;
}
long long getMinimumTime(int n, vector<int> from, vector<int> to, vector<int> weight, vector<int> del) {
int m = from.size();
vector<vector<pair<int, int>>> adj(n);
for (int i = 0; i < m; ++i) {
adj[from[i]].emplace_back(to[i], weight[i]);
adj[to[i]].emplace_back(from[i], weight[i]);
}
vector<ll> start = dijkstra(n, 0, adj);
vector<vector<ll>> dist = shortest(n, del, adj);
ll mini = minTime(n, del.size(), start, dist, del);
return (mini == INF) ? -1 : mini;
}
Optimizing Delivery โ