#include <bits/stdc++.h>
using namespace std;
int getMinimumMoves(string word) {
unordered_map<char, int> freq;
int moves = 0;
for (char c : word) {
freq[c]++;
}
for (auto& entry : freq) {
moves += entry.second / 2;
}
return moves;
}
Minimum length word β
Telegram:- @allcoding1
using namespace std;
int getMinimumMoves(string word) {
unordered_map<char, int> freq;
int moves = 0;
for (char c : word) {
freq[c]++;
}
for (auto& entry : freq) {
moves += entry.second / 2;
}
return moves;
}
Minimum length word β
Telegram:- @allcoding1
#include <iostream>
#include <vector>
#include <unordered_map>
#include <sstream>
using namespace std;
vector<string> computeParameterValue(vector<vector<string>>& sources) {
unordered_map<string, string> final_parameters;
vector<string> order_of_keys;
for (auto& source : sources) {
for (auto& pair : source) {
stringstream ss(pair);
string key, value;
getline(ss, key, ':');
getline(ss, value, ':');
if (final_parameters.find(key) == final_parameters.end()) {
order_of_keys.push_back(key);
}
final_parameters[key] = value;
}
}
vector<string> final_parameters_list;
for (auto& key : order_of_keys) {
final_parameters_list.push_back(final_parameters[key]);
}
return final_parameters_list;
}
Stock Analysis β
Telegram:- @allcoding1
#include <vector>
#include <unordered_map>
#include <sstream>
using namespace std;
vector<string> computeParameterValue(vector<vector<string>>& sources) {
unordered_map<string, string> final_parameters;
vector<string> order_of_keys;
for (auto& source : sources) {
for (auto& pair : source) {
stringstream ss(pair);
string key, value;
getline(ss, key, ':');
getline(ss, value, ':');
if (final_parameters.find(key) == final_parameters.end()) {
order_of_keys.push_back(key);
}
final_parameters[key] = value;
}
}
vector<string> final_parameters_list;
for (auto& key : order_of_keys) {
final_parameters_list.push_back(final_parameters[key]);
}
return final_parameters_list;
}
Stock Analysis β
Telegram:- @allcoding1
π2
static int getAnagramPeriod(String input_str) {
int n = input_str.length();
for (int period = 1; period <= n; period++) {
if (n % period == 0) {
String subString = input_str.substring(0, period);
boolean valid = true;
for (int i = 0; i < n; i += period) {
if (!isAnagram(subString, input_str.substring(i, i + period))) {
valid = false;
break;
}
}
if (valid) {
return period;
}
}
}
return -1;
}
static boolean isAnagram(String str1, String str2) {
char[] charArray1 = str1.toCharArray();
char[] charArray2 = str2.toCharArray();
Arrays.sort(charArray1);
Arrays.sort(charArray2);
return Arrays.equals(charArray1, charArray2);
}
Anagram Period β
Telegram:- @allcoding1
int n = input_str.length();
for (int period = 1; period <= n; period++) {
if (n % period == 0) {
String subString = input_str.substring(0, period);
boolean valid = true;
for (int i = 0; i < n; i += period) {
if (!isAnagram(subString, input_str.substring(i, i + period))) {
valid = false;
break;
}
}
if (valid) {
return period;
}
}
}
return -1;
}
static boolean isAnagram(String str1, String str2) {
char[] charArray1 = str1.toCharArray();
char[] charArray2 = str2.toCharArray();
Arrays.sort(charArray1);
Arrays.sort(charArray2);
return Arrays.equals(charArray1, charArray2);
}
Anagram Period β
Telegram:- @allcoding1
int solve(int N, vector<int> A, int T) {
int xa = 0;
for(int i=0; i<N; i++) {
xa ^= A[i];
}
int d = xa ^ T;
if(d == 0) return 0;
int ops = 0;
while(d > 0) {
ops += d & 1;
d >>= 1;
}
return ops;
}
Flip or flop β
Telegram:- @allcoding1
int xa = 0;
for(int i=0; i<N; i++) {
xa ^= A[i];
}
int d = xa ^ T;
if(d == 0) return 0;
int ops = 0;
while(d > 0) {
ops += d & 1;
d >>= 1;
}
return ops;
}
Flip or flop β
Telegram:- @allcoding1
π―EY is hiring for Data and Analytics
Expected Salary: 5-10 LPA
πApply here: https://eyglobal.yello.co/jobs/Zz403Fi4A5JV05N-0NtWSQ?job_board_id=c1riT--B2O-KySgYWsZO1Q
Expected Salary: 5-10 LPA
πApply here: https://eyglobal.yello.co/jobs/Zz403Fi4A5JV05N-0NtWSQ?job_board_id=c1riT--B2O-KySgYWsZO1Q
π―Amazon Off Campus Hiring 2024 : Recruitment for Freshers | Register Now
Eligibility:
Testing Associate, Device OS:
Bachelorβs degree
Knowledge of QA methodology and tools
Preferred:
B.E,B.Tech. , MSC IT and MCA
Good Communication
Testing Knowledge
Apply:- https://www.allcoding1.com/2024/02/amazon-off-campus-hiring-2024.html
Telegram:- @allcoding1
Eligibility:
Testing Associate, Device OS:
Bachelorβs degree
Knowledge of QA methodology and tools
Preferred:
B.E,B.Tech. , MSC IT and MCA
Good Communication
Testing Knowledge
Apply:- https://www.allcoding1.com/2024/02/amazon-off-campus-hiring-2024.html
Telegram:- @allcoding1
π2
int n=sc.nextInt(),i;
int a[]=new int[n];
for(i=0;i<n;i++) a[i]=sc.nextInt();
int dp[]=new int[n];
dp[0]=a[0];
if(n>1)
dp[1]=Math.max(a[0],a[1]);
if(n>2)
dp[2]=Math.max(a[0]+a[2],a[1]);
for( i=3;i<n;i++)
dp[i]=Math.max(a[i]+dp[i-2],dp[i-1]);
System.out.println(dp[n-1]);
Special Sum β
Intuit
int a[]=new int[n];
for(i=0;i<n;i++) a[i]=sc.nextInt();
int dp[]=new int[n];
dp[0]=a[0];
if(n>1)
dp[1]=Math.max(a[0],a[1]);
if(n>2)
dp[2]=Math.max(a[0]+a[2],a[1]);
for( i=3;i<n;i++)
dp[i]=Math.max(a[i]+dp[i-2],dp[i-1]);
System.out.println(dp[n-1]);
Special Sum β
Intuit
π1
allcoding1
Photo
class TreeNode:
def init(self, val):
self.val = val
self.children = []
def build_tree(units, relationships):
nodes = {i: TreeNode(units[i]) for i in range(len(units))}
for rel in relationships:
parent, child = rel
nodes[parent].children.append(nodes[child])
return nodes[0]
def max_electricity_per_floor(root):
max_electricity = 0
floor_electricity = {}
def dfs(node, level):
nonlocal max_electricity
if level not in floor_electricity:
floor_electricity[level] = 0
floor_electricity[level] += node.val
max_electricity = max(max_electricity, floor_electricity[level])
for child in node.children:
dfs(child, level + 1)
dfs(root, 0)
return max_electricity
num = int(input())
units = list(map(int, input().split()))
numRel, memConnect = map(int, input().split())
relationships = [tuple(map(int, input().split())) for _ in range(numRel)]
root = build_tree(units, relationships)
result = max_electricity_per_floor(root)
print(result)
Apartment one
@allcoding1
def init(self, val):
self.val = val
self.children = []
def build_tree(units, relationships):
nodes = {i: TreeNode(units[i]) for i in range(len(units))}
for rel in relationships:
parent, child = rel
nodes[parent].children.append(nodes[child])
return nodes[0]
def max_electricity_per_floor(root):
max_electricity = 0
floor_electricity = {}
def dfs(node, level):
nonlocal max_electricity
if level not in floor_electricity:
floor_electricity[level] = 0
floor_electricity[level] += node.val
max_electricity = max(max_electricity, floor_electricity[level])
for child in node.children:
dfs(child, level + 1)
dfs(root, 0)
return max_electricity
num = int(input())
units = list(map(int, input().split()))
numRel, memConnect = map(int, input().split())
relationships = [tuple(map(int, input().split())) for _ in range(numRel)]
root = build_tree(units, relationships)
result = max_electricity_per_floor(root)
print(result)
Apartment one
@allcoding1
π3β€1
int main() {
ll N;
cin >> N;
vector<ll> u(N);
for(ll i = 0; i < N; ++i) {
cin >> u[i];
}
ll M, X;
cin >> M >> X;
vector<vector<ll>> a(N);
for(ll i = 0; i < M; ++i) {
ll x, y;
cin >> x >> y;
a[x].push_back(y);
a[y].push_back(x);
}
vector<bool> v(N, false);
queue<ll> q;
q.push(0);
v[0] = true;
ll m = 0;
while(!q.empty()) {
ll s = q.size();
ll us = 0;
for(ll i = 0; i < s; ++i) {
ll n = q.front();
q.pop();
us += u[n];
for(ll nb : a[n]) {
if(!v[nb]) {
q.push(nb);
v[nb] = true;
}
}
}
m = max(m, us);
}
cout << m << endl;
return 0;
}
apartment
@allcoding1
ll N;
cin >> N;
vector<ll> u(N);
for(ll i = 0; i < N; ++i) {
cin >> u[i];
}
ll M, X;
cin >> M >> X;
vector<vector<ll>> a(N);
for(ll i = 0; i < M; ++i) {
ll x, y;
cin >> x >> y;
a[x].push_back(y);
a[y].push_back(x);
}
vector<bool> v(N, false);
queue<ll> q;
q.push(0);
v[0] = true;
ll m = 0;
while(!q.empty()) {
ll s = q.size();
ll us = 0;
for(ll i = 0; i < s; ++i) {
ll n = q.front();
q.pop();
us += u[n];
for(ll nb : a[n]) {
if(!v[nb]) {
q.push(nb);
v[nb] = true;
}
}
}
m = max(m, us);
}
cout << m << endl;
return 0;
}
apartment
@allcoding1
π1
int main() {
ll N;
cin >> N;
vector<ll> w(N);
for(ll i = 0; i < N; ++i) {
cin >> w[i];
}
vector<ll> s(N, 15);
for(ll i = N-2; i >= 0; --i) {
for(ll j = i+1; j < N; ++j) {
if(w[i] < w[j]) {
s[i] = 10;
for(ll k = j+1; k < N; ++k) {
if(w[j] > w[k]) {
s[i] = 5;
break;
}
}
break;
}
}
}
ll g = 0;
for(ll sc : s) {
g += sc;
}
cout << g << endl;
return 0;
}
chair manufacture
@allcoding1
ll N;
cin >> N;
vector<ll> w(N);
for(ll i = 0; i < N; ++i) {
cin >> w[i];
}
vector<ll> s(N, 15);
for(ll i = N-2; i >= 0; --i) {
for(ll j = i+1; j < N; ++j) {
if(w[i] < w[j]) {
s[i] = 10;
for(ll k = j+1; k < N; ++k) {
if(w[j] > w[k]) {
s[i] = 5;
break;
}
}
break;
}
}
}
ll g = 0;
for(ll sc : s) {
g += sc;
}
cout << g << endl;
return 0;
}
chair manufacture
@allcoding1
π4
Forwarded from allcoding1
π―SAS Off Campus Drive 2024 β Associate Software Engineer β Freshers | Rs 4-8 LPA
Job Role : Associate Software Developer
Qualification : B.E/B/Tech/M.E. / M.Tech
Experience : Freshers
Job Location : Pune
Package : Rs 4-8 LPA
Apply Now:- https://www.allcoding1.com/2024/02/sas-off-campus-drive-2024-associate_9.html?m=1
Telegram:- @allcoding1
Job Role : Associate Software Developer
Qualification : B.E/B/Tech/M.E. / M.Tech
Experience : Freshers
Job Location : Pune
Package : Rs 4-8 LPA
Apply Now:- https://www.allcoding1.com/2024/02/sas-off-campus-drive-2024-associate_9.html?m=1
Telegram:- @allcoding1
char solve(string o, string r) {
string res = "";
int j = 0;
for (int i = 0; i < o.size(); i++) {
if (o[i] != r[j]) {
res += o[i];
} else {
j++;
}
}
return res[0];
}
Tech Mahindra
telegram:- @allcoding1
string res = "";
int j = 0;
for (int i = 0; i < o.size(); i++) {
if (o[i] != r[j]) {
res += o[i];
} else {
j++;
}
}
return res[0];
}
Tech Mahindra
telegram:- @allcoding1
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin >> s;
int n;
cin >> n;
for (int i = n; i < s.size() + n; i++)
{
cout << s[i % s.size()];
}
return 0;
}
C++
Tech Mahindra
Telegram @allcoding1
using namespace std;
int main()
{
string s;
cin >> s;
int n;
cin >> n;
for (int i = n; i < s.size() + n; i++)
{
cout << s[i % s.size()];
}
return 0;
}
C++
Tech Mahindra
Telegram @allcoding1
π4
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin >> s;
int ans = 0;
map<char, int> m;
for (int i = 0; i < s.size(); i++)
{
m[s[i]]++;
}
for (auto x : m)
{
if (x.second == 1)
ans++;
}
cout << ans;
return 0;
}
Tech Mahindra
C++
Tech Mahindra
Telegram @allcoding1
using namespace std;
int main()
{
string s;
cin >> s;
int ans = 0;
map<char, int> m;
for (int i = 0; i < s.size(); i++)
{
m[s[i]]++;
}
for (auto x : m)
{
if (x.second == 1)
ans++;
}
cout << ans;
return 0;
}
Tech Mahindra
C++
Tech Mahindra
Telegram @allcoding1
π5