def getSubsequenceCount(s1, s2):
def count_subsequences(s1, s2, index1, index2):
if index1 == 3:
return 1
if index2 == len(s2):
return 0
count = count_subsequences(s1, s2, index1, index2 + 1)
if s1[index1] == s2[index2]:
count += count_subsequences(s1, s2, index1 + 1, index2 + 1)
return count
return count_subsequences(s1, s2, 0, 0)
Meesho โ
def count_subsequences(s1, s2, index1, index2):
if index1 == 3:
return 1
if index2 == len(s2):
return 0
count = count_subsequences(s1, s2, index1, index2 + 1)
if s1[index1] == s2[index2]:
count += count_subsequences(s1, s2, index1 + 1, index2 + 1)
return count
return count_subsequences(s1, s2, 0, 0)
Meesho โ
def maximum_learning(iv, articles, p):
size = len(articles)
art = [x * 2 for x in articles]
ivs = iv
return knap_sack_top_down(ivs, art, p, size)
def knap_sack_top_down(val, wt, W, n):
mat = [[0] * (W + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, W + 1):
if i == 0 or j == 0:
mat[i][j] = 0
elif wt[i - 1] <= j:
mat[i][j] = max(val[i - 1] + mat[i - 1][j - wt[i - 1]], mat[i - 1][j])
else:
mat[i][j] = mat[i - 1][j]
return mat[n][W]
Meesho โ
size = len(articles)
art = [x * 2 for x in articles]
ivs = iv
return knap_sack_top_down(ivs, art, p, size)
def knap_sack_top_down(val, wt, W, n):
mat = [[0] * (W + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, W + 1):
if i == 0 or j == 0:
mat[i][j] = 0
elif wt[i - 1] <= j:
mat[i][j] = max(val[i - 1] + mat[i - 1][j - wt[i - 1]], mat[i - 1][j])
else:
mat[i][j] = mat[i - 1][j]
return mat[n][W]
Meesho โ
import heapq
def getSeatsAllocation(arr):
n = len(arr)
ppl = [[] for i in range(2 * n + 4)]
for i, x in enumerate(arr):
ppl[x].append(i)
h = []
ans = [-1] * n
for pos in range(1, 2 * n + 1):
for i in ppl[pos]:
heapq.heappush(h, (-pos, i))
if len(h) > 0:
ans[heapq.heappop(h)[1]] = pos
return ans
Meesho โ
def getSeatsAllocation(arr):
n = len(arr)
ppl = [[] for i in range(2 * n + 4)]
for i, x in enumerate(arr):
ppl[x].append(i)
h = []
ans = [-1] * n
for pos in range(1, 2 * n + 1):
for i in ppl[pos]:
heapq.heappush(h, (-pos, i))
if len(h) > 0:
ans[heapq.heappop(h)[1]] = pos
return ans
Meesho โ
def max_tie_moments(n, moments):
max_tie_count = 0
current_difference = 0
for moment in moments:
bob_goals, noddy_goals = moment
difference = bob_goals - noddy_goals
if difference == current_difference:
max_tie_count += 1
elif difference > current_difference:
current_difference = difference
max_tie_count = 0
return max_tie_count
max_tie_count = 0
current_difference = 0
for moment in moments:
bob_goals, noddy_goals = moment
difference = bob_goals - noddy_goals
if difference == current_difference:
max_tie_count += 1
elif difference > current_difference:
current_difference = difference
max_tie_count = 0
return max_tie_count
def alternatingParityPermutations(n):
result = []
def backtrack(permutation, used):
if len(permutation) == n:
result.append(permutation.copy())
return
for i in range(1, n + 1):
if not used[i]:
if not permutation or (permutation[-1] % 2 != i % 2):
permutation.append(i)
used[i] = True
backtrack(permutation, used)
used[i] = False
permutation.pop()
used_numbers = [False] * (n + 1)
backtrack([], used_numbers)
return result
Meesho โ
result = []
def backtrack(permutation, used):
if len(permutation) == n:
result.append(permutation.copy())
return
for i in range(1, n + 1):
if not used[i]:
if not permutation or (permutation[-1] % 2 != i % 2):
permutation.append(i)
used[i] = True
backtrack(permutation, used)
used[i] = False
permutation.pop()
used_numbers = [False] * (n + 1)
backtrack([], used_numbers)
return result
Meesho โ
def binary_exponentiation(base, exponent, mod=None):
result = 1
base = base % mod if mod else base
while exponent > 0:
if exponent % 2 == 1:
result = (result * base) % mod if mod else result * base
base = (base * base) % mod if mod else base * base
exponent //= 2
return result
def calculate_expression(n):
mod = 10**9 + 7 # You can use a different modulus if needed
return (binary_exponentiation(26, n, mod) -
3 * binary_exponentiation(25, n, mod) -
n * binary_exponentiation(25, n-1, mod) +
3 * binary_exponentiation(24, n, mod) +
2 * n * binary_exponentiation(24, n-1, mod) -
binary_exponentiation(23, n, mod) -
n * binary_exponentiation(23, n-1, mod)) % mod
result = 1
base = base % mod if mod else base
while exponent > 0:
if exponent % 2 == 1:
result = (result * base) % mod if mod else result * base
base = (base * base) % mod if mod else base * base
exponent //= 2
return result
def calculate_expression(n):
mod = 10**9 + 7 # You can use a different modulus if needed
return (binary_exponentiation(26, n, mod) -
3 * binary_exponentiation(25, n, mod) -
n * binary_exponentiation(25, n-1, mod) +
3 * binary_exponentiation(24, n, mod) +
2 * n * binary_exponentiation(24, n-1, mod) -
binary_exponentiation(23, n, mod) -
n * binary_exponentiation(23, n-1, mod)) % mod
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name : Leap Finance
Role : Engineering Internship - 6 Months Internship
Batch : 2024/2023 passouts
Link : https://leapfinance.freshteam.com/jobs/IDtsNXR4UToB/engineering-internship
Role : Engineering Internship - 6 Months Internship
Batch : 2024/2023 passouts
Link : https://leapfinance.freshteam.com/jobs/IDtsNXR4UToB/engineering-internship
Freshteam
Hiring for Engineering Internship for Bengaluru - Internship
Posted by : Leap |
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name : Fractal
Role : Summer Internship
Batch : 2025 passouts
Link : https://fractal.wd1.myworkdayjobs.com/en-US/Careers/job/Mumbai/Summer-Project-Intern_SR-21908?q=Intern
Role : Summer Internship
Batch : 2025 passouts
Link : https://fractal.wd1.myworkdayjobs.com/en-US/Careers/job/Mumbai/Summer-Project-Intern_SR-21908?q=Intern
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin coachin program for 2nd year girls
https://linkedincoachinprogram-season5.splashthat.com/LI1?mcid=7151138277369032704&li_fat_id=7552cd3b-5125-4d81-bef5-7ef388b5769f
https://linkedincoachinprogram-season5.splashthat.com/LI1?mcid=7151138277369032704&li_fat_id=7552cd3b-5125-4d81-bef5-7ef388b5769f
Splashthat
LinkedIn CoachIn Program- Season 5
Learn more at: learning.linkedin.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Exciting Opportunity for MBA Grads at EY! ๐
EY is looking to onboard MBA graduates with a passion for Tech-Driven Business Process Improvement! If you meet the following criteria, this could be the opportunity you've been waiting for:
Criteria:
1. MBA from a tier-1 institute (2019, 2020, 2021, and 2022 batches)
2. 2-4 years of experience in management consulting from a tier-1 firm
3. Based out of Mumbai/ Delhi/ Bangalore and willing to travel for case work
4. Strong communication and interpersonal skills
If you fit the bill, don't miss out on this chance! Send your resumes to tathagata.ghosh1@in.ey.com and take the next step in your career with EY! ๐
EY is looking to onboard MBA graduates with a passion for Tech-Driven Business Process Improvement! If you meet the following criteria, this could be the opportunity you've been waiting for:
Criteria:
1. MBA from a tier-1 institute (2019, 2020, 2021, and 2022 batches)
2. 2-4 years of experience in management consulting from a tier-1 firm
3. Based out of Mumbai/ Delhi/ Bangalore and willing to travel for case work
4. Strong communication and interpersonal skills
If you fit the bill, don't miss out on this chance! Send your resumes to tathagata.ghosh1@in.ey.com and take the next step in your career with EY! ๐
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐BrowserStack is Hiring !!
Role: Automation Support Engineer
Batch: 2023
Expected CTC: 8-12 LPA
๐Apply here: https://browserstack.wd3.myworkdayjobs.com/en-US/External/job/India-Remote/Automation-Support-Engineer---2023-Batch-Graduates_JR101015
Role: Automation Support Engineer
Batch: 2023
Expected CTC: 8-12 LPA
๐Apply here: https://browserstack.wd3.myworkdayjobs.com/en-US/External/job/India-Remote/Automation-Support-Engineer---2023-Batch-Graduates_JR101015
Myworkdayjobs
Automation Support Engineer - 2023 Batch Graduates
Who are we and what do we do? BrowserStack is the world's leading software testing platform powering over two million tests every day across 19 global data centers. BrowserStack's products help developers build bug-free software for the 5 billion internetโฆ
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll solve(ll k, ll s) {
auto comb = [](ll n) {
return n * (n - 1) / 2;
};
if (k > 3 * s) return 0;
ll ans = comb(k + 2);
if (k > s) ans -= 3 * comb(k - s + 1);
if (k - 2 >= 2 * s) ans += 3 * comb(k - 2 * s);
return ans;
}
int main() {
ll n, s;
cin >> n >> s;
cout << solve(s,n) << endl;
return 0;
}
Distribute Car Toy
Service Now โ
#define ll long long
using namespace std;
ll solve(ll k, ll s) {
auto comb = [](ll n) {
return n * (n - 1) / 2;
};
if (k > 3 * s) return 0;
ll ans = comb(k + 2);
if (k > s) ans -= 3 * comb(k - s + 1);
if (k - 2 >= 2 * s) ans += 3 * comb(k - 2 * s);
return ans;
}
int main() {
ll n, s;
cin >> n >> s;
cout << solve(s,n) << endl;
return 0;
}
Distribute Car Toy
Service Now โ
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<vector<int>> freq(n, vector<int> (26, 0));
string s;
for(int i = 0; i < n; i++) {
string s;
cin >> s;
for(auto &ch : s)
freq[i][ch - 'a']++;
}
long long ans = 0;
for(int i = 0; i < 26; i++) {
int minValue = INT_MAX;
for(int j = 0; j < n; j++)
minValue = min(minValue, freq[j][i]);
ans += minValue;
}
cout << ans << endl;
}
Service Now โ
using namespace std;
int main() {
int n;
cin >> n;
vector<vector<int>> freq(n, vector<int> (26, 0));
string s;
for(int i = 0; i < n; i++) {
string s;
cin >> s;
for(auto &ch : s)
freq[i][ch - 'a']++;
}
long long ans = 0;
for(int i = 0; i < 26; i++) {
int minValue = INT_MAX;
for(int j = 0; j < n; j++)
minValue = min(minValue, freq[j][i]);
ans += minValue;
}
cout << ans << endl;
}
Service Now โ
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> nums(n);
for(int i = 0; i < n; i++) {
cin >> nums[i];
}
nums.erase(unique(nums.begin(), nums.end()), nums.end());
int sum = 0;
for(int i = 0; i < nums.size(); i++) {
sum += pow(2, nums[i]);
}
cout << sum << endl;
return 0;
}
Special sum โ
Service Now
using namespace std;
int main() {
int n;
cin >> n;
vector<int> nums(n);
for(int i = 0; i < n; i++) {
cin >> nums[i];
}
nums.erase(unique(nums.begin(), nums.end()), nums.end());
int sum = 0;
for(int i = 0; i < nums.size(); i++) {
sum += pow(2, nums[i]);
}
cout << sum << endl;
return 0;
}
Special sum โ
Service Now
#include<bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
multiset<int, greater<int>> s;
for(int i = 0; i < N; i++) {
int x;
cin >> x;
s.insert(x);
}
int count = 0;
while(!s.empty()) {
int x = *s.begin();
s.erase(s.begin());
if(s.empty() || *s.begin() != x) {
count++;
if(x / 2 > 0)
s.insert(x / 2);
} else {
s.erase(s.lower_bound(x), s.upper_bound(x));
}
}
cout << count << endl;
return 0;
}
Counting problem โ
Service Now
using namespace std;
int main() {
int N;
cin >> N;
multiset<int, greater<int>> s;
for(int i = 0; i < N; i++) {
int x;
cin >> x;
s.insert(x);
}
int count = 0;
while(!s.empty()) {
int x = *s.begin();
s.erase(s.begin());
if(s.empty() || *s.begin() != x) {
count++;
if(x / 2 > 0)
s.insert(x / 2);
} else {
s.erase(s.lower_bound(x), s.upper_bound(x));
}
}
cout << count << endl;
return 0;
}
Counting problem โ
Service Now
#include<bits/stdc++.h>
using namespace std;
string solve(string s, int k) {
string vowels = "aeiou";
string result = "";
for (char c : s) {
if (vowels.find(c) != string::npos) {
k += 2;
} else {
k += 1;
}
result += to_string(k * int(c)) + " ";
}
return result;
}
int main() {
string s;
int k;
cin >> s >> k;
cout << solve(s, k) << endl;
return 0;
}
Enciphering a String โ
Service Now
using namespace std;
string solve(string s, int k) {
string vowels = "aeiou";
string result = "";
for (char c : s) {
if (vowels.find(c) != string::npos) {
k += 2;
} else {
k += 1;
}
result += to_string(k * int(c)) + " ";
}
return result;
}
int main() {
string s;
int k;
cin >> s >> k;
cout << solve(s, k) << endl;
return 0;
}
Enciphering a String โ
Service Now