Diwali Contest โ
long getMaxPrisonHole(int n, int m, vector<int> x, vector<int> y) {
vector<bool> xb(n+1, true);
vector<bool> yb(m+1, true);
for(int i : x) {
xb[i] = false;
}
for(int i : y) {
yb[i] = false;
}
long cx = 0, xm = LONG_MIN, cy = 0, ym = LONG_MIN;
for(int i = 0; i < xb.size(); i++) {
if(xb[i]) {
cx = 0;
} else {
cx++;
xm = max(cx, xm);
}
}
for(int i = 0; i < yb.size(); i++) {
if(yb[i]) {
cy = 0;
} else {
cy++;
ym = max(cy, ym);
}
}
return (xm+1) * (ym+1);
}
Swiggy
Prison Break โ
vector<bool> xb(n+1, true);
vector<bool> yb(m+1, true);
for(int i : x) {
xb[i] = false;
}
for(int i : y) {
yb[i] = false;
}
long cx = 0, xm = LONG_MIN, cy = 0, ym = LONG_MIN;
for(int i = 0; i < xb.size(); i++) {
if(xb[i]) {
cx = 0;
} else {
cx++;
xm = max(cx, xm);
}
}
for(int i = 0; i < yb.size(); i++) {
if(yb[i]) {
cy = 0;
} else {
cy++;
ym = max(cy, ym);
}
}
return (xm+1) * (ym+1);
}
Swiggy
Prison Break โ
public static int selectStock(int saving, int[] currentValue, int[] futureValue) {
int n = currentValue.length;
int[][] dp = new int[n + 1][saving + 1];
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= saving; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= currentValue[i - 1]) {
dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - currentValue[i - 1]] + futureValue[i - 1] - currentValue[i - 1]);
}
}
}
return dp[n][saving];
}.
Swiggy
Selecting Stocks โ
int n = currentValue.length;
int[][] dp = new int[n + 1][saving + 1];
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= saving; j++) {
dp[i][j] = dp[i - 1][j];
if (j >= currentValue[i - 1]) {
dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - currentValue[i - 1]] + futureValue[i - 1] - currentValue[i - 1]);
}
}
}
return dp[n][saving];
}.
Swiggy
Selecting Stocks โ
#include <bits/stdc++.h>
using namespace std;
int jumps(int flagHeight, int bigJump) {
}.
Swiggy
Jump to The Flag โ
using namespace std;
int jumps(int flagHeight, int bigJump) {
return flagHeight / bigJump+flagheight% bigJump;
}.
Swiggy
Jump to The Flag โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company โ Bristol Myers Squibb
Role โ Data Scientist
Exp. โ 0-3 yrs
Responsibilities โ
The Data Scientist I will play a crucial role in supporting operational analytics across GPS to ensure products continue to serve most pressing GPS analytics needs, with potential opportunities to build new advanced analytics capabilities such as predictive modelling, simulation, and optimization. The Data Scientist I should have a strong interest in solving business problems, and an eagerness to work on all parts of the analytics value chain, from partnering with IT on data pipelines to operationalizing predictive models in the service of our patients around the world.
Skills โ
โขProven experience in a data and analytics role, including direct development experience.
โขExperience working with large datasets, data visualization tools, statistical software packages and platforms (specifically R, Python, advanced SQL, Domino, AWS, GitHub, dbt, Tableau)
โขExperience with major GPS applications (SAP, Oracle, LIMS, Infinity, MES) is a plus.
โขExperience with biotech product development, manufacturing operations, supply chain, and quality control is a significant plus.
โขExperience in the biopharma industry a plus.
Apply Here โ https://www.linkedin.com/jobs/view/3912975400
Role โ Data Scientist
Exp. โ 0-3 yrs
Responsibilities โ
The Data Scientist I will play a crucial role in supporting operational analytics across GPS to ensure products continue to serve most pressing GPS analytics needs, with potential opportunities to build new advanced analytics capabilities such as predictive modelling, simulation, and optimization. The Data Scientist I should have a strong interest in solving business problems, and an eagerness to work on all parts of the analytics value chain, from partnering with IT on data pipelines to operationalizing predictive models in the service of our patients around the world.
Skills โ
โขProven experience in a data and analytics role, including direct development experience.
โขExperience working with large datasets, data visualization tools, statistical software packages and platforms (specifically R, Python, advanced SQL, Domino, AWS, GitHub, dbt, Tableau)
โขExperience with major GPS applications (SAP, Oracle, LIMS, Infinity, MES) is a plus.
โขExperience with biotech product development, manufacturing operations, supply chain, and quality control is a significant plus.
โขExperience in the biopharma industry a plus.
Apply Here โ https://www.linkedin.com/jobs/view/3912975400
heights = [int(i) for i in input().split()]
freq_dict = {}
for h in heights:
if h in freq_dict:
freq_dict[h] += 1
else:
freq_dict[h] = 1
for h in sorted(freq_dict):
print(h, freq_dict[h])
freq_dict = {}
for h in heights:
if h in freq_dict:
freq_dict[h] += 1
else:
freq_dict[h] = 1
for h in sorted(freq_dict):
print(h, freq_dict[h])
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int numDecodings(string msg) {
int MOD = 1000000007;
int n = msg.size();
vector<long long> dp(n + 1, 0);
dp[0] = 1;
if (msg[0] == '0')
dp[1] = 0;
else if (msg[0] == '*')
dp[1] = 9;
else
dp[1] = 1;
for (int i = 2; i <= n; ++i) {
if (msg[i - 1] == '0') {
if (msg[i - 2] == '1' || msg[i - 2] == '2')
dp[i] += dp[i - 2];
else if (msg[i - 2] == '*')
dp[i] += 2 * dp[i - 2];
} else if (msg[i - 1] >= '1' && msg[i - 1] <= '9') {
dp[i] += dp[i - 1];
if (msg[i - 2] == '1' || (msg[i - 2] == '2' && msg[i - 1] <= '6'))
dp[i] += dp[i - 2];
else if (msg[i - 2] == '*') {
if (msg[i - 1] <= '6')
dp[i] += 2 * dp[i - 2];
else
dp[i] += dp[i - 2];
}
} else if (msg[i - 1] == '*') {
dp[i] += 9 * dp[i - 1];
if (msg[i - 2] == '1')
dp[i] += 9 * dp[i - 2];
else if (msg[i - 2] == '2')
dp[i] += 6 * dp[i - 2];
else if (msg[i - 2] == '*')
dp[i] += 15 * dp[i - 2];
}
dp[i] %= MOD;
}
return dp[n];
}
Number of ways decode โ
#include <string>
#include <vector>
using namespace std;
int numDecodings(string msg) {
int MOD = 1000000007;
int n = msg.size();
vector<long long> dp(n + 1, 0);
dp[0] = 1;
if (msg[0] == '0')
dp[1] = 0;
else if (msg[0] == '*')
dp[1] = 9;
else
dp[1] = 1;
for (int i = 2; i <= n; ++i) {
if (msg[i - 1] == '0') {
if (msg[i - 2] == '1' || msg[i - 2] == '2')
dp[i] += dp[i - 2];
else if (msg[i - 2] == '*')
dp[i] += 2 * dp[i - 2];
} else if (msg[i - 1] >= '1' && msg[i - 1] <= '9') {
dp[i] += dp[i - 1];
if (msg[i - 2] == '1' || (msg[i - 2] == '2' && msg[i - 1] <= '6'))
dp[i] += dp[i - 2];
else if (msg[i - 2] == '*') {
if (msg[i - 1] <= '6')
dp[i] += 2 * dp[i - 2];
else
dp[i] += dp[i - 2];
}
} else if (msg[i - 1] == '*') {
dp[i] += 9 * dp[i - 1];
if (msg[i - 2] == '1')
dp[i] += 9 * dp[i - 2];
else if (msg[i - 2] == '2')
dp[i] += 6 * dp[i - 2];
else if (msg[i - 2] == '*')
dp[i] += 15 * dp[i - 2];
}
dp[i] %= MOD;
}
return dp[n];
}
Number of ways decode โ
def getPasswordStrength(passwords, common_words):
result = []
for password in passwords:
is_weak = False
if password.lower() in common_words:
is_weak = True
else:
for word in common_words:
if word.lower() in password.lower():
is_weak = True
break
if password.isdigit():
is_weak = True
if password.islower() or password.isupper():
is_weak = True
if len(password) < 6:
is_weak = True
result.append("weak" if is_weak else "strong")
return result
Password Validation โ
result = []
for password in passwords:
is_weak = False
if password.lower() in common_words:
is_weak = True
else:
for word in common_words:
if word.lower() in password.lower():
is_weak = True
break
if password.isdigit():
is_weak = True
if password.islower() or password.isupper():
is_weak = True
if len(password) < 6:
is_weak = True
result.append("weak" if is_weak else "strong")
return result
Password Validation โ
๐1๐ฑ1
def groupTransactions(transactions):
counts = {}
for item in transactions:
if item in counts:
counts[item] += 1
else:
counts[item] = 1
sorted_items = sorted(counts.items(), key=lambda x: (-x[1], x[0]))
result = []
for item, count in sorted_items:
result.append(f"{item} {count}")
return result
Group Transactionsโ
counts = {}
for item in transactions:
if item in counts:
counts[item] += 1
else:
counts[item] = 1
sorted_items = sorted(counts.items(), key=lambda x: (-x[1], x[0]))
result = []
for item, count in sorted_items:
result.append(f"{item} {count}")
return result
Group Transactionsโ
def getPasswordStrength(passwords, common_words):
result = []
for password in passwords:
is_weak = False
if password.lower() in common_words:
is_weak = True
else:
for word in common_words:
if word.lower() in password.lower():
is_weak = True
break
if password.isdigit():
is_weak = True
if password.islower() or password.isupper():
is_weak = True
if len(password) < 6:
is_weak = True
result.append("weak" if is_weak else "strong")
return result
GetPasswordStrengthโ
def binary_converter(binary, base='d'):
binary_str = ''.join(map(str, binary))
decimal_num = int(binary_str, 2)
if base == 'd':
return str(decimal_num)
elif base == 'b':
return bin(decimal_num)[2:]
elif base == 'o':
return oct(decimal_num)[2:]
elif base == 'x':
return hex(decimal_num)[2:]
else:
return "Invalid base"
Python Binary converter โ
binary_str = ''.join(map(str, binary))
decimal_num = int(binary_str, 2)
if base == 'd':
return str(decimal_num)
elif base == 'b':
return bin(decimal_num)[2:]
elif base == 'o':
return oct(decimal_num)[2:]
elif base == 'x':
return hex(decimal_num)[2:]
else:
return "Invalid base"
Python Binary converter โ
def find_suspicious_users(logs, threshold):
transaction_count = {}
for log in logs:
sender, recipient, _ = log.split()
transaction_count[sender] = transaction_count.get(sender, 0) + 1
transaction_count[recipient] = transaction_count.get(recipient, 0) + 1
suspicious_users = [user_id for user_id, count in transaction_count.items() if count >= threshold]
return sorted(suspicious_users, key=int)
Find Suspicious Usersโ
transaction_count = {}
for log in logs:
sender, recipient, _ = log.split()
transaction_count[sender] = transaction_count.get(sender, 0) + 1
transaction_count[recipient] = transaction_count.get(recipient, 0) + 1
suspicious_users = [user_id for user_id, count in transaction_count.items() if count >= threshold]
return sorted(suspicious_users, key=int)
Find Suspicious Usersโ