uk
Feedback
Leetcode with dani

Leetcode with dani

Відкрити в Telegram

Join us and let's tackle leet code questions together: improve your problem-solving skills Preparing for coding interviews learning new algorithms and data structures connect with other coding enthusiasts

Показати більше
1 258
Підписники
Немає даних24 години
+17 днів
-730 день
Архів дописів
here is the first question of A2SV weekly contest For G6 i will post each question with their answer🖊 A. Pens and PencilsProblem Statement Tomorrow is a difficult day for Polycarp: he has to attend lectures and practical classes at the university! He writes lectures with pens and practicals with pencils. • One pen lasts for c lectures. • One pencil lasts for d practicals. • His pencil case can hold at most k writing tools in total. Can Polycarp pack enough pens and pencils to cover the day? --- ▎Input FormatFirst line: An integer t (1 ≤ t ≤ 100), the number of test cases. • Each test case: Five integers a, b, c, d, ka: Number of lectures – b: Number of practical classes – c: Lectures per pen – d: Practicals per pencil – k: Maximum tools in the pencil case --- ▎Output Format For each test case, output: • Two integers x y, where: – x: Number of pens – y: Number of pencils • Or output -1 if it’s not possible to pack enough tools. --- ▎Example Input
3
7 5 4 5 8
7 5 4 5 2
20 53 45 26 4
Example Output
2 1
-1
1 3
--- ▎ExplanationTest Case 1: – Needs ceil(7/4) = 2 pens and ceil(5/5) = 1 pencil. – Total = 2 + 1 = 3 ≤ 8 (possible). • Test Case 2: – Needs 2 pens and 1 pencil. – Total = 2 + 1 = 3 > 2 (not possible). • Test Case 3: – Needs 1 pen (ceil(20/45)) and 3 pencils (ceil(53/26)). – Total = 1 + 3 = 4 = 4 (possible). --- ▎Sample Code (Python)
t = int(input())
for _ in range(t):
    a, b, c, d, k = map(int, input().split())
    pens_needed = (a + c - 1) // c  # Ceiling of a/c
    pencils_needed = (b + d - 1) // d  # Ceiling of b/d
    if pens_needed + pencils_needed <= k:
        print(pens_needed, pencils_needed)
    else:
        print(-1)

photo content

if u have better ideas, i would love to hear and collaborate with u .please feel free to contact me with this bot @zprogramming_bot

i want to make this channel more usefull for u so .what type of post do u want to see more often?
Anonymous voting

Repost from N/a
Built something cool! 🚀 Verify is my personal project—an API for free, unlimited phone verification using Telegram. No SMS c
Built something cool! 🚀 Verify is my personal project—an API for free, unlimited phone verification using Telegram. No SMS costs, simple integration, and optional self-hosting. 🔗 Check it out: https://verify.yonathan.tech Would love your feedback!

Hey Developers! Let me introduce you to an amazing project: an unlimited free phone verification API created by my friend Yonatan. Check it out!

photo content

a, b, c = 1, 2, 4 
for i in range(4, n+1):
    a, b, c = b, c, a + b + c
return c

a, b= 1, 2
for i in range(3,n+1):
    a, b  = b, a + b
return b

What if the question asks to use 1,2 and 3 steps?

can u solve this question? the logic is simple but it may take while to figure it out 70. Climbing Stairs Solved Easy You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 step 2. 1 step + 2 steps 3. 2 steps + 1 step Constraints: 1 <= n <= 45 see the question in leetcode

Check this website to practice for the INSA test. There are some rumors that INSA takes questions from this site. Mensa IQ Test Leetcode with dani I'll share any new info as soon as I get it!

interview mode🤓
interview mode🤓

photo content

i am trying it and it seems interesting
i am trying it and it seems interesting

I know this one is a little bit harder question — I don’t expect you to get the solution right away. But I’m sharing it because trying to solve this will help you deeply understand the Binary Indexed Tree (BIT) concept. You might not get it in one go — and that’s okay. Just keep pushing, and eventually it will click. 🔗 Problem: Create Sorted Array through Instructions 🎥 Helpful video/Ans: YouTube Explanation Once you solve this, you’ll be confident with how BIT works in real problems — from prefix sums to range frequency queries.

this is typical BIT quesiton start with this, i will add more Range Sum

Guys, have you heard of the BIT (Binary Indexed Tree)? I learned about it a few days ago — it transforms both prefix‐sum queries and point updates from O(n) down to O(log n)! In problems with frequent range‐sum queries and multiple updates, a simple prefix‐sum array fails (you’ll hit TLE). BIT handles every query and update in O(log n) time, so even with many operations your total cost stays around O(n log n) instead of O(n²). Give it a try next time you see “range‑sum with updates”! s if u want to know more about it give me thumbs up i will share some questions that can be solved with with this algo with a video explanation about the topic

🧠 INSA Summer Camp Past Questions — Test Your Logic! 1️⃣ Family Logic Given: + = husband / = sister × = son - = wife What does W × Y / Z mean? A) Son of Z's brother B) Son of Z's sister C) Daughter of Z's sister D) Daughter of Z's sister 2️⃣ Code Puzzle A girl student sleeps → Vtp htj 1 A priest teaches tonight → Vxp wyz 2 A queen speaks tonight → Tsp wyz 1 "A lady speaks tonight"? A) Vtp Tsp B) Tsp Wyz C) Wyz 2 htj D) Tsp Wyz 1 3️⃣ Word Match Imaginative Dynamic Learning = Sue Deb Can Complex Dynamic System = Sue Rob Be Complex Revolutionary Thinking = Mol De Be What is Sue Be? A) Revolutionary System B) Dynamic System C) Complex Dynamic D) Imaginative Learning 👇👇👇 Answers: 1️⃣ B 2️⃣ D 3️⃣ B 🔥 Comment your score! More coming soon.