Leetcode with dani
1.29K subscribers
202 photos
14 videos
56 files
243 links
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
Download Telegram
๐ŸŒŸ Daily Algorithm Challenge! ๐ŸŒŸ

Starting today, Iโ€™ll be posting a new question every day to help us prepare for A2SV in November! ๐Ÿ’ปโœจ

๐Ÿ—“ Challenge yourself and share your solutions!

Letโ€™s sharpen our skills together. Ready to dive in?

Stay tuned for the first question! ๐Ÿš€

๐Ÿ‘ Like this post if you're excited for the daily algorithm challenges!

Your support motivates us to keep pushing our limits and learning together. Letโ€™s make this journey fun and productive! ๐Ÿš€
๐Ÿ”ฅ7โค1๐Ÿ‘1๐ŸŽ‰1
๐Ÿ‘5
the answer is 042
๐Ÿ‘2
Topic of This Week Linked List
Leetcode with dani pinned ยซTopic of This Week Linked Listยป
Leetcode with dani
Topic of This Week Linked List
we will work on this algorithm for the coming 7 days.
Forwarded from DOGS Community
Final day to earn free DOGS! ๐Ÿค‘๐Ÿค‘๐Ÿค‘

This is itโ€”your last chance to earn free $DOGS! Donโ€™t miss out! ๐Ÿถ
Use your final opportunity and make the most of it today ๐Ÿ˜Ž๐Ÿฆด

Get your $DOGS now!

#DOGS
Please open Telegram to view this post
VIEW IN TELEGRAM
it is really a good podcast with a graduate from AAU in Information system degree
21. Merge Two Sorted Lists (Easy)

Problem:

You are given the heads of two sorted linked lists, list1 and list2.

Your task is to merge these two lists into one sorted linked list. The merged list should be formed by splicing together the nodes of list1 and list2.

Return: The head of the newly merged sorted linked list.

Examples:

Example 1:

Input: list1 = [1, 2, 4], list2 = [1, 3, 4]
Output: [1, 1, 2, 3, 4, 4]
Example 2:

Input: list1 = [], list2 = []
Output: []
Example 3:

Input: list1 = [], list2 = [0]
Output: [0]
๐Ÿ‘3
try this question
https://t.me/cexio_tap_bot?start=1723654213580170
CEXP tokens farming major upgrade! Two is better than one! Join my squad, and let's double the fun (and earnings ๐Ÿค‘)! CEX.IO Power Tap! ๐Ÿš€
Find Middle of the Linked List
#Q19
Given a Singly Linked List, the task is to find the middle of the linked list. If the number of nodes are even, then there would be two middle nodes, so return the second middle node.

Example:

Input: linked list = 1 -> 2 -> 3 -> 4 -> 5
Output: 3
Explanation: There are 5 nodes in the linked list and there is one middle node whose value is 3.
๐Ÿ‘3
Maximise the number of toys that can be purchased with amount K

Given an array consisting of the cost of toys. Given an integer K depicting the amount of money available to purchase toys. Write a program to find the maximum number of toys one can buy with the amount K.

Note: One can buy only 1 quantity of a particular toy.

Examples:

Input: N = 10, K = 50, cost = { 1, 12, 5, 111, 200, 1000, 10, 9, 12, 15 }
Output: 6
Explanation: Toys with amount 1, 5, 9, 10, 12, and 12 can be purchased resulting in a total amount of 49. Hence, maximum number of toys is 6.
Leetcode with dani
Maximise the number of toys that can be purchased with amount K Given an array consisting of the cost of toys. Given an integer K depicting the amount of money available to purchase toys. Write a program to find the maximum number of toys one can buy withโ€ฆ
answer:
def max_toys(cost, K):
cost.sort()
count = 0
total_cost = 0

for price in cost:
if total_cost + price <= K:
total_cost += price
count += 1
else:
break

return count

N = 10
K = 50
cost = [1, 12, 5, 111, 200, 1000, 10, 9, 12, 15]
print(max_toys(cost, K)) # Output: 6
i could not post in the previous days for some reason, and I apologize for that. I will start posting from now on
๐Ÿ‘4โ˜ƒ1