static final int MOD = (int)1e9 + 7;
public static int countGoodSubsequences(String word) {
int[] freq = new int[26];
int maxFreq = 0;
for (char c : word.toCharArray()) {
freq[c - 'a']++;
maxFreq = Math.max(maxFreq, freq[c - 'a']);
}
int n = word.length();
long[] factorial = new long[maxFreq + 1];
long[] invFactorial = new long[maxFreq + 1];
factorial[0] = invFactorial[0] = 1;
for (int i = 1; i <= maxFreq; i++) {
factorial[i] = factorial[i - 1] * i % MOD;
}
invFactorial[maxFreq] = modInverse(factorial[maxFreq], MOD);
for (int i = maxFreq - 1; i >= 1; i--) {
invFactorial[i] = invFactorial[i + 1] * (i + 1) % MOD;
}
long totalGoodSequences = 0;
for (int k = 1; k <= maxFreq; k++) {
long total_k = 1;
boolean hasValidChar = false;
for (int i = 0; i < 26; i++) {
if (freq[i] >= k) {
hasValidChar = true;
long c = comb(freq[i], k, factorial, invFactorial);
total_k = total_k * (c + 1) % MOD;
}
}
if (hasValidChar) {
total_k = (total_k - 1 + MOD) % MOD;
totalGoodSequences = (totalGoodSequences + total_k) % MOD;
}
}
return (int) totalGoodSequences;
}
static long modInverse(long a, int mod) {
return modPow(a, mod - 2, mod);
}
static long modPow(long a, long b, int mod) {
long result = 1;
a %= mod;
while (b > 0) {
if ((b & 1) == 1)
result = result * a % mod;
a = a * a % mod;
b >>= 1;
}
return result;
}
static long comb(int n, int k, long[] factorial, long[] invFactorial) {
if (k > n) return 0;
return factorial[n] * invFactorial[k] % MOD * invFactorial[n - k] % MOD;
}
Good sequence
LinkedIn โ
โค1๐1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
typedef long long ll;
long findMinIncrease(vector<int> threadSize) {
int n = threadSize.size();
if(n < 3) return 0;
vector<ll> required_increase(n, 0);
for(int i=1; i<n-1; ++i){
ll needed = max((ll)threadSize[i-1], (ll)threadSize[i+1]) + 1;
if(threadSize[i] < needed){
required_increase[i] = needed - (ll)threadSize[i];
}
else{
required_increase[i] = 0;
}
}
pair<int, ll> prev0 = {0, 0};
pair<int, ll> prev1 = {-1, 0};
for(int i=0; i<n; ++i){
pair<int, ll> current0 = {0, 0};
pair<int, ll> current1 = {0, 0};
if(i == 0 || i == n-1){
if(prev0.first > prev1.first){
current0 = prev0;
}
else if(prev0.first < prev1.first){
current0 = prev1;
}
else{
current0.first = prev0.first;
current0.second = min(prev0.second, prev1.second);
}
prev0 = current0;
prev1 = {-1, 0};
continue;
}
if(prev0.first > prev1.first){
current0.first = prev0.first;
current0.second = prev0.second;
}
else if(prev0.first < prev1.first){
current0.first = prev1.first;
current0.second = prev1.second;
}
else{
current0.first = prev0.first;
current0.second = min(prev0.second, prev1.second);
}
if(prev0.first != -1){
current1.first = prev0.first + 1;
current1.second = prev0.second + required_increase[i];
}
else{
current1.first = -1;
current1.second = 0;
}
pair<int, ll> new_prev0 = current0;
pair<int, ll> new_prev1;
if(current1.first != -1){
new_prev1 = current1;
}
else{
new_prev1 = {-1, 0};
}
prev0 = new_prev0;
prev1 = new_prev1;
}
pair<int, ll> final_ans;
if(prev0.first > prev1.first){
final_ans = prev0;
}
else if(prev0.first < prev1.first){
final_ans = prev1;
}
else{
final_ans.first = prev0.first;
final_ans.second = min(prev0.second, prev1.second);
}
return final_ans.second;
}
LinkedIn โ
long findMinIncrease(vector<int> threadSize) {
int n = threadSize.size();
if(n < 3) return 0;
vector<ll> required_increase(n, 0);
for(int i=1; i<n-1; ++i){
ll needed = max((ll)threadSize[i-1], (ll)threadSize[i+1]) + 1;
if(threadSize[i] < needed){
required_increase[i] = needed - (ll)threadSize[i];
}
else{
required_increase[i] = 0;
}
}
pair<int, ll> prev0 = {0, 0};
pair<int, ll> prev1 = {-1, 0};
for(int i=0; i<n; ++i){
pair<int, ll> current0 = {0, 0};
pair<int, ll> current1 = {0, 0};
if(i == 0 || i == n-1){
if(prev0.first > prev1.first){
current0 = prev0;
}
else if(prev0.first < prev1.first){
current0 = prev1;
}
else{
current0.first = prev0.first;
current0.second = min(prev0.second, prev1.second);
}
prev0 = current0;
prev1 = {-1, 0};
continue;
}
if(prev0.first > prev1.first){
current0.first = prev0.first;
current0.second = prev0.second;
}
else if(prev0.first < prev1.first){
current0.first = prev1.first;
current0.second = prev1.second;
}
else{
current0.first = prev0.first;
current0.second = min(prev0.second, prev1.second);
}
if(prev0.first != -1){
current1.first = prev0.first + 1;
current1.second = prev0.second + required_increase[i];
}
else{
current1.first = -1;
current1.second = 0;
}
pair<int, ll> new_prev0 = current0;
pair<int, ll> new_prev1;
if(current1.first != -1){
new_prev1 = current1;
}
else{
new_prev1 = {-1, 0};
}
prev0 = new_prev0;
prev1 = new_prev1;
}
pair<int, ll> final_ans;
if(prev0.first > prev1.first){
final_ans = prev0;
}
else if(prev0.first < prev1.first){
final_ans = prev1;
}
else{
final_ans.first = prev0.first;
final_ans.second = min(prev0.second, prev1.second);
}
return final_ans.second;
}
LinkedIn โ
๐1
#define INF INT_MAX
int minimumStressLevel(int N, vector<vector<int>>& abw, int X, int Y) {
vector<vector<pair<int, int>>> graph(N + 1);
for (auto& road : abw) {
int a = road[0], b = road[1], w = road[2];
graph[a].push_back({b, w});
graph[b].push_back({a, w});
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
vector<int> dist(N + 1, INF);
pq.push({0, X});
dist[X] = 0;
while (!pq.empty()) {
int u = pq.top().second;
int stress = pq.top().first;
pq.pop();
if (u == Y) return stress;
for (auto& neighbor : graph[u]) {
int v = neighbor.first;
int w = neighbor.second;
int new_stress = max(stress, w);
if (new_stress < dist[v]) {
dist[v] = new_stress;
pq.push({new_stress, v});
}
}
}
return -1;
}
ROBIN HOODโ
Probo (Intern)
int minimumStressLevel(int N, vector<vector<int>>& abw, int X, int Y) {
vector<vector<pair<int, int>>> graph(N + 1);
for (auto& road : abw) {
int a = road[0], b = road[1], w = road[2];
graph[a].push_back({b, w});
graph[b].push_back({a, w});
}
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
vector<int> dist(N + 1, INF);
pq.push({0, X});
dist[X] = 0;
while (!pq.empty()) {
int u = pq.top().second;
int stress = pq.top().first;
pq.pop();
if (u == Y) return stress;
for (auto& neighbor : graph[u]) {
int v = neighbor.first;
int w = neighbor.second;
int new_stress = max(stress, w);
if (new_stress < dist[v]) {
dist[v] = new_stress;
pq.push({new_stress, v});
}
}
}
return -1;
}
ROBIN HOODโ
Probo (Intern)
๐1
#include <bits/stdc++.h>
using namespace std;
string getPerfectExecutionString(string& category) {
vector<int> freq(26, 0);
for (char& x : category) {
freq[x - 'a']++;
}
string temp;
string ans;
int p = 0;
for (int i = 0; i < 26; i++) {
while (!temp.empty() && temp.back() - 'a' <= i) {
ans.push_back(temp.back());
temp.pop_back();
}
while (freq[i]) {
if (category[p] - 'a' == i) {
ans.push_back(category[p]);
} else {
temp.push_back(category[p]);
}
freq[category[p++] - 'a']--;
}
}
while (!temp.empty()) {
ans.push_back(temp.back());
temp.pop_back();
}
return ans;
}
Get perfect executing string โ
DE Shaw
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
#include <bits/stdc++.h> using namespace std; string getPerfectExecutionString(string& category) { vector<int> freq(26, 0); for (char& x : category) { freq[x - 'a']++; } string temp; string ans; int p = 0; for (intโฆ
void dfs(vll &arr,int n,int m,int i,int j,vl &ans,ll val,ll mini){
if(i==n-1 and j==m-1){
ans.pb(mini);
return;
}
if(i+1<n and j<m){
dfs(arr,n,m,i+1,j,ans,val+arr[i+1][j],min(mini,val+arr[i+1][j]));
}
if(i<n and j+1<m){
dfs(arr,n,m,i,j+1,ans,val+arr[i][j+1],min(mini,val+arr[i][j+1]));
}
}
void solve()
{
ll n,m;
cin>>n>>m;
vll arr(n,vl(m));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
vl ans;
dfs(arr,n,m,0,0,ans,arr[0][0],arr[0][0]);
sort(all(ans));
if(ans[0]>0){
cout<<0<<endl;
return;
}
cout<<abs(ans[0])+1<<endl;
debug(ans);
}
Mario โ
if(i==n-1 and j==m-1){
ans.pb(mini);
return;
}
if(i+1<n and j<m){
dfs(arr,n,m,i+1,j,ans,val+arr[i+1][j],min(mini,val+arr[i+1][j]));
}
if(i<n and j+1<m){
dfs(arr,n,m,i,j+1,ans,val+arr[i][j+1],min(mini,val+arr[i][j+1]));
}
}
void solve()
{
ll n,m;
cin>>n>>m;
vll arr(n,vl(m));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
vl ans;
dfs(arr,n,m,0,0,ans,arr[0][0],arr[0][0]);
sort(all(ans));
if(ans[0]>0){
cout<<0<<endl;
return;
}
cout<<abs(ans[0])+1<<endl;
debug(ans);
}
Mario โ
โค1๐ฅ1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Send resume to : hr@wittybrains.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Send your updated resume: Career@crystalvoxxltd.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Zeta is searching for SDE Freshers in #Hyderabad! Are you a #2024EngineeringGrad ready to shape the future of Banking Tech? Join our Rocket Ship and make an impact. #Hiringpost #ZetaSDErole #2024EngineerGrads
Apply now:
https://docs.google.com/forms/u/0/d/e/1FAIpQLScYwsRaJ7-OXGKYS3Ta3J1CpWMH4iw6GFEgs3si6t3Vklf_ZQ/viewform?usp=send_form&pli=1
Apply now:
https://docs.google.com/forms/u/0/d/e/1FAIpQLScYwsRaJ7-OXGKYS3Ta3J1CpWMH4iw6GFEgs3si6t3Vklf_ZQ/viewform?usp=send_form&pli=1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name : Coinbase
Role : SDE 1
Batch : 2023/2022 passouts
CTC : 24-28 LPA
Link : https://www.coinbase.com/en-gb/careers/positions/6230378?gh_jid=6230378&gh_src=20687b321us
Role : SDE 1
Batch : 2023/2022 passouts
CTC : 24-28 LPA
Link : https://www.coinbase.com/en-gb/careers/positions/6230378?gh_jid=6230378&gh_src=20687b321us
Coinbase
Software Engineer, Emerging Talent , Remote - India - Coinbase
Coinbase is a secure online platform for buying, selling, transferring, and storing cryptocurrency.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Fynd is hiring for Full Stack Intern
Apply here: https://www.linkedin.com/jobs/view/4046723664/?alternateChannel=search
Apply here: https://www.linkedin.com/jobs/view/4046723664/?alternateChannel=search
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Synopsys is hiring for Software Engineer
Experience: 0 - 1 years
Expected Salary: 7-15 LPA
Apply here: https://careers.synopsys.com/job/-/-/44408/71068434688?codes=OT
๐MSCI is hiring for Data Engineer (Associate)
Experience: 0 - 1 year's
Expected Salary: 14-25 LPA
Apply here: https://careers.msci.com/job/data/pune/data-engineer-associate/2024-1929?mode=apply&iis=LinkedIn
๐Genrobotics is hiring for Software Engineer Trainee
Experience: 0 - 1 year's
Apply here: https://www.linkedin.com/jobs/view/4046131453/?alternateChannel=search
๐Qualitest is hiring for Grad Engineer
Experience: 0 - 1 year's
Expected Salary: 4-7 LPA
Apply here: https://careers.qualitestgroup.com/job/Bangalore-Grad-Engineer-560045/30301944/
Like for more โค๏ธ
All the best ๐
Experience: 0 - 1 years
Expected Salary: 7-15 LPA
Apply here: https://careers.synopsys.com/job/-/-/44408/71068434688?codes=OT
๐MSCI is hiring for Data Engineer (Associate)
Experience: 0 - 1 year's
Expected Salary: 14-25 LPA
Apply here: https://careers.msci.com/job/data/pune/data-engineer-associate/2024-1929?mode=apply&iis=LinkedIn
๐Genrobotics is hiring for Software Engineer Trainee
Experience: 0 - 1 year's
Apply here: https://www.linkedin.com/jobs/view/4046131453/?alternateChannel=search
๐Qualitest is hiring for Grad Engineer
Experience: 0 - 1 year's
Expected Salary: 4-7 LPA
Apply here: https://careers.qualitestgroup.com/job/Bangalore-Grad-Engineer-560045/30301944/
Like for more โค๏ธ
All the best ๐
Company
Working at Synopsys
Browse available job openings at Synopsys
๐1
class FibonacciIterator:
def __init__(self, n):
self.prev = 0
self.curr = 1
self.count = 0
self.n = n
def __iter__(self):
return self
def __next__(self):
if self.count >= self.n:
raise StopIteration
fib = self.prev
self.prev, self.curr = self.curr, self.prev + self.curr
self.count += 1
return fib
Custom Iterator โ
Servicenow
def priceCheck(products, productPrices, productSold, soldPrice):
price_map = {}
for i in range(len(products)):
price_map[products[i]] = productPrices[i]
error_count = 0
for j in range(len(productSold)):
correct_price = price_map[productSold[j]]
if soldPrice[j] != correct_price:
error_count += 1
return error_count
IBMโ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Mithuna Srinika on LinkedIn: #deltaelectronics #freshers #freshersgroup #trainee #powerelectronicsโฆ | 73 comments
#DeltaElectronics hiring for #Freshers!
Role & responsibilities
- Implement embedded control algorithms using tools such as MATLAB/Simulink and DSP platformsโฆ | 73 comments on LinkedIn
Role & responsibilities
- Implement embedded control algorithms using tools such as MATLAB/Simulink and DSP platformsโฆ | 73 comments on LinkedIn
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Disperz is hiring Associate Software Engineer
For 2024, 2025 grads
Location: Chennai
https://disprz.keka.com/careers/jobdetails/68865?source=linkedin
For 2024, 2025 grads
Location: Chennai
https://disprz.keka.com/careers/jobdetails/68865?source=linkedin
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Inmobi
Role: SDE 1 (Android)
YOE: 0-2 years
Apply: https://docs.google.com/forms/d/e/1FAIpQLSeNNZBxJjnxJP9LoYYw5TACItpmbYHfPorVttZtANEkjObi-g/viewform
Role: SDE 1 (Android)
YOE: 0-2 years
Apply: https://docs.google.com/forms/d/e/1FAIpQLSeNNZBxJjnxJP9LoYYw5TACItpmbYHfPorVttZtANEkjObi-g/viewform
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Vinvoe is hiring Software Developer Trainee
For 2024, 2025 grads
Location: Gurugram
https://vinove.keka.com/careers/jobdetails/32816
For 2024, 2025 grads
Location: Gurugram
https://vinove.keka.com/careers/jobdetails/32816
Keka
Trainee - Software Development
Knowledge, Skills and Other Abilities:Good understanding of the system-oriented approachStrong analytical and logical skills to address work-related problemsSelf-motivated, team player, and result-orientedGood communication and problem-solving skillsAbilityโฆ