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 โ
let fs = require("fs");
function longestSubstringTwoDistinct(s) {
let maxLen = 0;
let startIndex = 0;
let charIndexMap = new Map();
for (let i = 0; i < s.length; i++) {
charIndexMap.set(s[i], i);
if (charIndexMap.size > 2) {
let minIndex = Math.min(...charIndexMap.values());
charIndexMap.delete(s[minIndex]);
startIndex = minIndex + 1;
}
maxLen = Math.max(maxLen, i - startIndex + 1);
}
return maxLen;
}
function Main(arg) {
let inputString = String(arg);
return longestSubstringTwoDistinct(inputString);
}
Valid Paris
Victoria Secret โ
Victoria Secret โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Wassem Mohd on LinkedIn: #malaysia #internship #malaysia #software | 10 comments
EasyEat is hiring technology interns in #Malaysia
We are looking for three interns with a strong academic background with a degree in computer science orโฆ | 10 comments on LinkedIn
We are looking for three interns with a strong academic background with a degree in computer science orโฆ | 10 comments on LinkedIn
#include<bits/stdc++.h>
using namespace std;
vector<int> getExecTime(int n, vector<string> logs) {
vector<int> res(n, 0);
stack<int> st;
int prev = 0;
for(string log : logs) {
stringstream ss(log);
string buf;
getline(ss, buf, ':');
int id = stoi(buf);
getline(ss, buf, ':');
string type = buf;
getline(ss, buf, ':');
int time = stoi(buf);
if(!st.empty()) {
res[st.top()] += time - prev;
}
prev = time;
if(type == "start") {
st.push(id);
} else {
res[st.top()]++;
st.pop();
prev++;
}
}
return res;
}
IBMโ
using namespace std;
vector<int> getExecTime(int n, vector<string> logs) {
vector<int> res(n, 0);
stack<int> st;
int prev = 0;
for(string log : logs) {
stringstream ss(log);
string buf;
getline(ss, buf, ':');
int id = stoi(buf);
getline(ss, buf, ':');
string type = buf;
getline(ss, buf, ':');
int time = stoi(buf);
if(!st.empty()) {
res[st.top()] += time - prev;
}
prev = time;
if(type == "start") {
st.push(id);
} else {
res[st.top()]++;
st.pop();
prev++;
}
}
return res;
}
IBMโ
Maximum quirknessโ
ll ans=LLONG_MIN;
i=0;
ll sum=0;
set<ll> s;
while(i<n)
{
if(i)
ans=max(ans,sum+a[i]+c*i-*s.begin());
s.insert(sum+c*i);
sum+=a[i];
i++;
}
cout ยซ ans ยซ "\n";
ll ans=LLONG_MIN;
i=0;
ll sum=0;
set<ll> s;
while(i<n)
{
if(i)
ans=max(ans,sum+a[i]+c*i-*s.begin());
s.insert(sum+c*i);
sum+=a[i];
i++;
}
cout ยซ ans ยซ "\n";
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Maximum quirknessโ
ll ans=LLONG_MIN; i=0; ll sum=0; set<ll> s; while(i<n) { if(i) ans=max(ans,sum+a[i]+c*i-*s.begin()); s.insert(sum+c*i); sum+=a[i]; i++; } cout ยซ ans ยซ "\n";
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Neelabhra B. on LinkedIn: #laidoff #market #hiring #jobs #hyland #laidoff #openpositions #hiringโฆ | 12 comments
Update: Referred and replied to most of the applicants. Closing further referrals for now.
Happy Holidays, everyone!
While some of us are enjoying, thereโฆ | 12 comments on LinkedIn
Happy Holidays, everyone!
While some of us are enjoying, thereโฆ | 12 comments on LinkedIn
๐3