HCL Recruitment(allcoding1_official).pdf
2.7 MB
π9β€2π―1
π―GlobalLogic off Campus Drive 2023 | Associate Analyst | Gurgaon | Rs 3.5-4.5 LPA
Job Role:- Associate Analyst
Qualification:- Any Graduate
Batch:- Any Batch
Salary/CTC:- Rs 3.5-4.5 LPA
Apply Now;- http://www.allcoding1.com
Video:- https://youtube.com/shorts/tWPfvbhtPgI?feature=share
Telegram:- @allcoding1_official
Job Role:- Associate Analyst
Qualification:- Any Graduate
Batch:- Any Batch
Salary/CTC:- Rs 3.5-4.5 LPA
Apply Now;- http://www.allcoding1.com
Video:- https://youtube.com/shorts/tWPfvbhtPgI?feature=share
Telegram:- @allcoding1_official
π39π3β€βπ₯2π2β€1
def gameWinner(colors):
currPlayer = "wendy"
prevPlayer = ""
winner = ""
while True:
moveMade = False
if currPlayer == "wendy":
whiteIndex = colors.find("www")
if whiteIndex = -1:
# 3 consecutive whites found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(whiteIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "bob"
else:
blackIndex = colors.find("bbb")
if blackIndex != -1:
# 3 consecutive blacks found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(blackIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "wendy"
# if no moves possible break
if not moveMade:
winner = prevPlayer
break
return winner
print(gameWinner("wwwbb"))
Python 3
Game Winner
JP Morgan
Telegram:- @allcoding1_official
currPlayer = "wendy"
prevPlayer = ""
winner = ""
while True:
moveMade = False
if currPlayer == "wendy":
whiteIndex = colors.find("www")
if whiteIndex = -1:
# 3 consecutive whites found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(whiteIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "bob"
else:
blackIndex = colors.find("bbb")
if blackIndex != -1:
# 3 consecutive blacks found, remove the middle one
colorsBuilder = list(colors)
colorsBuilder.pop(blackIndex + 1)
colors = "".join(colorsBuilder)
moveMade = True
prevPlayer = currPlayer
currPlayer = "wendy"
# if no moves possible break
if not moveMade:
winner = prevPlayer
break
return winner
print(gameWinner("wwwbb"))
Python 3
Game Winner
JP Morgan
Telegram:- @allcoding1_official
π26π₯2π1
allcoding1_official
def cardinalitySort(nums): return sorted(nums, key=lambda num: [bin(num).count('1'), num]) Cardinality sorting
#include <bits/stdc++.h>
using namespace std;
bool checkbit(int n,int i){
return n&(1<<i);
}
bool cmp(const pair<int,int> &a,const pair<int,int>&b){
return a.second<b.second;
}
int main() {
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
vector<pair<int,int>> v;
for(int i=0;i<n;i++){
int c=0;
for(int j=0;j<31;j++){
if(checkbit(a[i],j)) c++;
}
v.push_back({a[i],c});
}
int idx = 0;
sort(v.begin(),v.end(),cmp);
for(auto it : v){
a[idx++] = it.first;
cout<<it.second<<" ";
}
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
return 0;
}
C++
Telegram:- @allcoding1_official
using namespace std;
bool checkbit(int n,int i){
return n&(1<<i);
}
bool cmp(const pair<int,int> &a,const pair<int,int>&b){
return a.second<b.second;
}
int main() {
int n;cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
vector<pair<int,int>> v;
for(int i=0;i<n;i++){
int c=0;
for(int j=0;j<31;j++){
if(checkbit(a[i],j)) c++;
}
v.push_back({a[i],c});
}
int idx = 0;
sort(v.begin(),v.end(),cmp);
for(auto it : v){
a[idx++] = it.first;
cout<<it.second<<" ";
}
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
return 0;
}
C++
Telegram:- @allcoding1_official
π16β€1
def minimumCost(price):
n = len(price)
price.append(0)
ans = float('inf')
last = {price[0]: 0}
for i in range(1, n):
v = price[i]
price[i] += price[i - 1]
if last.get(v) != None:
ans = min(ans, price[i] - price[last[v]] + v)
last[v] = i
return ans if ans != float('inf') else -1
n = int(input())
price = list(map(int,input().split(' ')))
print(minimumCost(price))
Python 3
Amazon
Telegram:- @allcoding1_official
n = len(price)
price.append(0)
ans = float('inf')
last = {price[0]: 0}
for i in range(1, n):
v = price[i]
price[i] += price[i - 1]
if last.get(v) != None:
ans = min(ans, price[i] - price[last[v]] + v)
last[v] = i
return ans if ans != float('inf') else -1
n = int(input())
price = list(map(int,input().split(' ')))
print(minimumCost(price))
Python 3
Amazon
Telegram:- @allcoding1_official
π11β€1
string getLongestRegex(string a, string b, string c)
{
const size_t n = a.size();
int idx = -1;
for (int i = 0; i < n; i++) {
if (c[i] != a[i] && c[i] != b[i]) { idx = i; }
}
if (idx == -1) return "-1";
string res;
for (int i = 0; i < n; i++) {
if (i == idx) {
string cur = "[";
for (int j = 'A'; j <= 'Z'; j++) if (j != c[i]) cur += j;
cur += "]";
res += cur;
} else {
res += "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]";
}
}
return res;
}
C++
Amazon
Telegram:- @allcoding1_official
{
const size_t n = a.size();
int idx = -1;
for (int i = 0; i < n; i++) {
if (c[i] != a[i] && c[i] != b[i]) { idx = i; }
}
if (idx == -1) return "-1";
string res;
for (int i = 0; i < n; i++) {
if (i == idx) {
string cur = "[";
for (int j = 'A'; j <= 'Z'; j++) if (j != c[i]) cur += j;
cur += "]";
res += cur;
} else {
res += "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]";
}
}
return res;
}
C++
Amazon
Telegram:- @allcoding1_official
π25β€4
π
ΎοΈFree off cost
πALL IT companies (materials, exams questions & Answers paper's)
πALL software courses with certification
π ΎοΈFree off cost
Join now π
@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
β Please send with your friends and college groups
πALL IT companies (materials, exams questions & Answers paper's)
πALL software courses with certification
π ΎοΈFree off cost
Join now π
@Allcodingsolution
@Allcodingsolution
@Allcodingsolution
β Please send with your friends and college groups
π40β€5π5π1
Both conclusions I and II are not definitely true based on the information provided.
Tech Mahindra exam Ans
@allcoding1_official
Tech Mahindra exam Ans
@allcoding1_official
π2