Code_sagar
الذهاب إلى القناة على Telegram
If anyone want paid help contact here: @code_sagar
إظهار المزيد3 085
المشتركون
لا توجد بيانات24 ساعات
لا توجد بيانات7 أيام
لا توجد بيانات30 أيام
أرشيف المشاركات
3 085
https://x.com/Technol00668627/status/1753779762995118438?s=20
Fresher job posted 🤞🤞🤞🤞
Check it fast, like and follow💗
3 085
Zoho hiring!!!!
Role: Software developer
Batch : upto 2024
https://x.com/Technol00668627/status/1751998294689972405?s=20
3 085
int LCM(int a,int b)
{
return (a*b)/(__gcd(a,b));
}
void solve()
{
int n;cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int cnt = 0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
int x = LCM(a[i],a[j]);
int y = __gcd(a[i],a[j]);
if(x-y==0)
{
cnt++;
}
}
}
cout<<cnt<<endl;
}
@code_sagar
3 085
def binary_to_dna(binary_input):
mapping = {'00': 'A', '01': 'C', '10': 'G', '11': 'T'}
dna_sequence = ''
for i in range(0, len(binary_input), 2):
pair = binary_input[i:i+2]
dna_sequence += mapping[pair]
return dna_sequence
binary_input = '000001001011101010010110011'
output = binary_to_dna(binary_input)
print(output)
DNA
3 085
def validate_user_and_generate_token(user_id, password, num_digits):
"""Checks user credentials, generates a token if valid, and displays appropriate messages."""
users = ["user1", "pass1", "user2", "pass2", "user3", "pass3", "user4", "pass4", "user5", "pass5"]
if user_id in users and users[users.index(user_id) + 1] == password:
token = generate_palindrome_token(num_digits)
print(f"Welcome {user_id} and the generated token is: token-{token}")
else:
print("User ID or password is not valid. Please try again.")
def generate_palindrome_token(num_digits):
"""Generates the first palindrome number with the specified number of digits."""
num = 1
while len(str(num)) != num_digits or str(num) != str(num)[::-1]:
num += 1
return num
IBM CODE @code_sagar
3 085
📌GeeksforGeeks is Hiring !!
Role: SDE I
Experience: Upto 1 year's
Expected CTC: 9-16 LPA
Apply here: https://geeksforgeeks.org/jobs/geeksforgeeks-fullstack-developer
3 085
#include <bits/stdc++.h>
using namespace std;
vector<int> solution(vector<int> a, int n, int k) {
vector<int> v;
deque<int> dq;
for (int i = 0; i < n; i++) {
while (!dq.empty() && dq.front() <= i - k)
dq.pop_front();
while (!dq.empty() && a[dq.back()] <= a[i])
dq.pop_back();
dq.push_back(i);
if (i >= k - 1)
v.push_back(a[dq.front()]);
}
return v;
}
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
vector<int> result = solution(a, n, k);
for (int i = 0; i < result.size(); i++)
cout << result[i] << " ";
return 0;
}.
//cricket match ✅
Zeta
Telegram:- @code_sagar
3 085
NPCI EXAM
Help available
Very few Slots available.
Check our past Results.
100% Clearance Guarantee
Contact @code_sagar
Book Your Slot fast.
3 085
3 085
📌Juspay is Hiring !!
Role: Software Engineer
Batch: 2020, 2021 and 2022
Apply here- https://assessment.hackerearth.com/challenges/new/hiring/juspay-developer-hiring-challenge-bangalore-january-2024/
3 085
def max_points(chocolates,initial):
chocolates=sorted(chocolates)
points=1
l=[1]
i=0
while i < len(chocolates):
if chocolates[i]<=initial:
initial=initial-chocolates[i]
points+=1
i+=1
else:
points-=1
initial+=chocolates[-1]
chocolates.pop()
l.append(points)
return max(l)
chocolates_list = list(map(int, input().split())) # Input list of chocolates
initial_chocolates = int(input()) # Initial chocolates Bittu has
result = max_points(chocolates_list, initial_chocolates)
print(result,end="")
Choclate Code
TCS CODEVITA @code_sagar
PYTHON3
3 085
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y,x1,y1,x2,y2;
cin>>x>>y>>x1>>y1>>x2>>y2;
x=abs(x);
y=abs(y);
x1=abs(x1);
y1=abs(y1);
x2=abs(x2);
y2=abs(y2);
int r1 = ceil(sqrt(((x1-x)*(x1-x))+((y1-y)*(y1-y))));
int r2 = ceil(sqrt(((x2-x)*(x2-x))+((y2-y)*(y2-y))));
int a1 = ceil(3.14*r1*r1);
int a2 = ceil(3.14*r2*r2);
if(a2>a1)
{
int e = a2-a1;
int f = ceil(sqrt(e));
int g = f*f;
int h = g-e;
int i = h*20;
cout<<"Krishna ";
cout<<i;
}
else if(a1>a2)
{
int p = a1-a2;
int q = p*20;
cout<<"Shiva ";
cout<<q;
}
else if(a1==a2)
{
cout<<"-1";
}
}
FencingProblem:
C++
TCS CODEVITA
@code_sagar
3 085
import math
mapval = {
"add": -1,
"sub": -2,
"mul": -3,
"rem": -4,
"pow": -5,
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9
}
def values():
global mapval
mapval = {
"add": -1,
"sub": -2,
"mul": -3,
"rem": -4,
"pow": -5,
"zero": 0,
"one": 1,
"two": 2,
"three": 3,
"four": 4,
"five": 5,
"six": 6,
"seven": 7,
"eight": 8,
"nine": 9
}
def generate_value(s, stack):
s += 'c'
str_val = ""
sn = ""
for char in s:
if char == 'c':
if str_val not in mapval:
return False
sn += str(mapval[str_val])
str_val = ""
else:
str_val += char
ans = int(sn)
stack.append(ans)
return True
def solve_this(stack1, stack2):
while stack1:
top = stack1.pop()
if top < 0 and len(stack2) < 2:
return "expression is not complete or invalid"
elif top < 0:
val1 = stack2.pop()
val2 = stack2.pop()
if top == -1:
new_val = val1 + val2
elif top == -4:
new_val = val1 % val2
elif top == -2:
new_val = val1 - val2
elif top == -3:
new_val = val1 * val2
elif top == -5:
new_val = int(math.pow(val1, val2))
stack2.append(new_val)
else:
stack2.append(top)
return str(stack2[0]) if len(stack2) == 1 else "expression is not complete or invalid"
def perform_task(s, stack):
i = 0
str_val = ""
s += " "
count_of_c = 0
while i < len(s):
if s[i] == ' ':
if str_val not in mapval:
if count_of_c == 0:
return "expression evaluation stopped invalid words present"
if not generate_value(str_val, stack):
return "expression evaluation stopped invalid words present"
count_of_c = 0
else:
stack.append(mapval[str_val])
str_val = ""
else:
if s[i] == 'c':
count_of_c += 1
str_val += s[i]
i += 1
return ""
def solve_it(s):
st = []
st1 = []
an = perform_task(s, st)
if an != "":
return an
return solve_this(st, st1)
def main():
values()
s = input()
print(solve_it(s))
if name == "main":
main()
No Sybmol one code
@code_sagar
3 085
def minimum_vehicles(weights, max_limit): # Filter out zero weights and sort the remaining weights in descending order
sorted_weights = sorted(filter(lambda x: x != 0, weights), reverse=True)
left, right = 0, len(sorted_weights) - 1 vehicles = 0
while left <= right: if sorted_weights[left] + sorted_weights[right] <= max_limit:
right -= 1 left += 1
vehicles += 1
return vehicles
# Example usage:weights = list(map(int, input().split()))
max_limit = int(input())
result = minimum_vehicles(weights, max_limit)
print(result,end="")
Maximum vehicle code
Codevita @code_sagar
3 085
def getTotalExecutionTime(n, logs):
stack = []
result = [0] * n
prev_time = 0
for log in logs:
function_id, action, timestamp = log[:-1].split()
function_id, timestamp = int(function_id), int(timestamp)
if action == "start":
if stack:
result[stack[-1]] += timestamp - prev_time
stack.append(function_id)
prev_time = timestamp
else:
result[stack.pop()] += timestamp - prev_time + 1
prev_time = timestamp + 1
return result
n = 3
logs = ["0:start:0", "2:start:4", "2:end:5", "1:start:7", "1:end:10", "0:end:11"]
output = getTotalExecutionTime(n, logs)
print(output)
All cases passed
@code_sagar
