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 день
Архів дописів
1 258
here is the first question of A2SV weekly contest For G6 i will post each question with their answer
▎🖊 A. Pens and Pencils
▎Problem 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 Format
• First line: An integer t (1 ≤ t ≤ 100), the number of test cases.
• Each test case: Five integers a, b, c, d, k
– a: 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--- ▎Explanation • Test 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)1 258
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
1 258
i want to make this channel more usefull for u so .what type of post do u want to see more often?
1 258
Repost from N/a
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!
1 258
Hey Developers! Let me introduce you to an amazing project: an unlimited free phone verification API created by my friend Yonatan. Check it out!
1 258
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
1 258
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!
1 258
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.
1 258
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
1 258
🧠 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.
Вже доступно! Дослідження Telegram за 2025 — головні інсайти року 
