LeetCodin
1.4K subscribers
160 photos
3 videos
2 files
303 links
LeetCode 1700+
🇺🇿🇺🇸
Motto: Победа любит подготовку

- Getting ready for FAANG | FAANGga tayyorlanamiz
- Data Structures and Algorithms | Ma'lumotlar tuzilmalari va Algoritmlar
- SWE at Deloitte 🇺🇸
- LeetCode: https://leetcode.com/tbekpro/
Download Telegram
🇬🇧Recursion

🇺🇿O'zbekchasi pastda⬇️

Hi, guys! I wanted to cover one more important topic which is very useful when you are solving problems on binary trees. It is recursion.

There is a good small course on LeetCode which explains what is recursion and how does it work. I urge you to go thru it.

Here is the link to the course: Recursion
Links to my solutions for some problems from this course: Reverse String recursively and Swap Nodes in Pairs Recursively

Let's do it!
🔥2👍1
🇺🇿 Rekursiya

Binar daraxtga oid masalalarni yechishda ko'pincha rekursiya ishlatiladi. Shuning uchun rekursiya mavzusini takrorlash va mustahkamlash kerak deb o'ylayman.

LeetCode-da rekursiya haqida yaxshi kurs bor. Unda rekursiya nima ekanligi va qanday ishlashi tushuntirilgan. Shu kichkina kursni o'rganib chiqishingizga chaqiraman.

Kursga havola: Recursion
Shu kursdagi masalalarni men ham yechganman:
Reverse String recursively va Swap Nodes in Pairs Recursively

Let's do it!
👍4
🇬🇧Recursion: Recurrence Relation

Hi, guys! Let's go on with recursion. Let's cover the second chapter of yesterday's course dedicated to recursion. Today's section is recurrence relation. I'll be brief:

Two main concepts.
1. Base case: the case in recursive method where you compute the answer without any further recursion calls.
2. Recurrence relation: the relationship between the result of a problem and the result of its subproblems.

You can read more about it in this article here

My solutions to problems from this section:
206. Reverse Linked List - Solution
700. Search in Binary Search Tree - Solution
118. Pascal's Triangle - Solution

Keep coding!
🔥3👍1
🇺🇿 Rekursiya: Takrorlanish munosabati (Recurrence Relation)

Hammaga salom! Keling, rekursiya mavzusini sizlar bilan davom etaylik. Kechagi kursning rekursiyaga bag'ishlangan ikkinchi qismini o'tamiz. Bugungi bo'lim - akrorlanishlarning munosabati.

Shu qismda ikkita asosiy tushuncha bor:
1. Asosiy holat - bu rekursiv usulda javobni boshqa rekursiyaviy chaqiruvlarsiz hisoblaydigan holat.
2. Takrorlanish munosabati: muammoning natijasi va uning kichik muammolari natijalari o'rtasidagi munosabat.

Bu haqda ko'proq ma'lumotni ushbu maqolada o'qishingiz mumkin

Ushbu bo'limdagi masalalarga men yozgan yechimlarim:
206. Reverse Linked List - Solution
700. Search in Binary Search Tree - Solution
118. Pascal's Triangle - Solution

Kod yozishni to'xtatmang!
👍6
🇬🇧Recursion: Offtop

Hi, guys! Today I didn't have time to post something interesting. No worries - posts are coming 😁

I'll be brief. I want to share my small victory:
Today I was able to write a solution for medium level problem and it ran in 0 ms (100% faster) and was 98% more memory efficient.

Problem: 1026. Maximum Difference Between Node and Ancestor

And link to my solution: Solution

Siiiuuuu!
🍾5❤1👍1🔥1
🇺🇿Rekursiya: Offtop

Hammaga salom! Bugun qiziq narsa yozishga ulgurmadim. Xavotir olmang - hammasi oldinda 😁

Ko'p yozmayman.
Men kichik g'alabam bilan bo'lishmoqchiman:
Bugun men o'rta darajadagi masala uchun 0 ms (100% tezroq) ishlaydigan va 98% samaraliroq xotira ishlatadigan yechim yoza oldim. Agar qiziq bo'lsa:

Masala: 1026. Maximum Difference Between Node and Ancestor

Men yozgan yechim: Solution

Siiiuuuuu!
🎉11👍2
🇬🇧Recursion: Memoization (from Recursion course on LeetCode)

Hi, guys! Let's cover memoization technique utilized in recursion. It's used to increase the speed of your code by caching (saving and storing) the results of methods. Thus you will not repeatedly execute methods with the same inputs and just retrieve cached results instead.

Link to the article: Memoization

You can try solving problems from that chapter:
Problem 1: 509. Fibonacci Number
My solution

Problem 2: 70. Climbing Stairs
My solution 2

I hope this was useful! 😀
❤1👍1
🇺🇿Rekursiya: Memoizatsiya - Xotirada saqlash (LeetCode-dagi Rekursiya kursidan)

Hammaga salom! Keling, rekursiyada qo'llaniladigan memoizatsiya texnikasini ko'rib chiqaylik. U method-larning natijalarini keshlash (saqlash) orqali kodingizning tezligini oshirish uchun ishlatiladi. Shunday qilib, siz bir xil kirishlar bilan method-larni qayta-qayta bajarmaysiz va buning o'rniga keshlangan natijalarni olasiz.

Maqolaga havola: Memoization

Siz ushbu bobdagi masalalarni yechishga urinib ko'rishingiz mumkin:

1-masala: 509. Fibonacci Number
My solution

2-masala: 70. Climbing Stairs
My solution 2

Umid qilamanki, bu post siz uchun foydali bo'ldi! 😀
👍6
🇬🇧Recursion: Complexity Analysis🤓

Hi, guys! Today I will leave a link to another part of Recursion course on LeetCode: Complexity Analysis. Let's read through 3 topics and try to solve 2 problems😄:

Problem 1: 104. Maximum Depth of Binary Tree
My solution: Java Solution

Problem 2 is a medium level problem🙈: 50. Pow(x, n)
Actually, I was able to solve it, but my solution is not recursive and is not that fast comparing to others' solutions. I will leave a link here: Java Solution. Note that this problem and problems in the next chapter are really challenging😬😬.

Let's discuss these problems in the comments🤓🤓🤓
👍3❤1
🇺🇿Rekursiya: Algoritmning murakkabligini tahlil qilish 🤓

Hammaga salom! Bugun men LeetCode-dagi Algoritmning murakkabligini tahlil qilish bo'yicha Rekursiya kursining boshqa qismiga havola qoldiraman: havola. Keling bugun 3 ta maqolani o'qib chiqaylik va 2 ta masalani yechishga harakat qilaylik😄:

1-masala: 104. Maximum Depth of Binary Tree
Men yozgan yechim: Java Solution

2-masala - o'rta darajali masala🙈: 50. Pow(x, n)
Shuni aytib o'tishim kerakki, aslida men bu masalani yecha oldim, lekin mening yechimim rekursiv emas va boshqalarning yechimlari bilan solishtirganda unchalik tez emas. Men bu erda havola qoldiraman: Java solution. E'tibor bering, bu masala va keyingi bobdagi masalalar haqiqatan ham qiyin😬😬.

Keling, ushbu masalalarni comment-larda muhokama qilaylik🤓🤓🤓
👍5🤩1
🇬🇧Recursion: Conclusion.

I could not solve two problems🥲.

Hi, guys! Before I tell you about the difficult problems I'd like to say that the short course on recursion came to its end and today the only thing left is the last chapter: Conclusion.

Here we have 3 problems: one is easy and the rest are medium level. For me these last two problems are challenging and I haven't solved them yet, but I keep trying by coming back to them from time to time.

I'll leave all the links below:
Problem 1: 21. Merge Two Sorted Lists.
My solution: Solution.

And two tasks that are still in progress:
Problem 2: 779. K-th Symbol in Grammar. Here my algorithm ran out of time. 😅

Problem 3: 95. Unique Binary Search Trees II. Here I still figure out the best approach. 🙊

Were you able to find solutions to all of them?

Leetcode
🤔1
🇺🇿Rekursiya: Yakuniy qismi .

Men bu bobdan ikkita masalaning yechimini hali topmadim🥲.

Hammaga salom! Men uchun qiyin bo'lgan masalar haqida yozishdan avval, rekursiya kursi bo'yicha LeetCode-ning qisqa kursi o'z nihoyasiga yetdi va, shunday qilib, oxirgi bob qoldi: Yakuniy bob.

Bu maqolada kurs bo'yicha xulosadan tashqari 3ta masala bor: bittasi oson, qolganlari esa o'rta darajalik. Men uchun oxirgi ikkitasini yechish qiyin bo'ldi va ularga hali yechimlarini topa olganim yo'q. Ammo vaqti-vaqti bilan ularga qaytib yangi usullar bilan yechib ko'rishga harakat qilaman.

Birinchi masala: 21. Merge Two Sorted Lists.
Men yozgan kod: Solution.

Va qolgan ikkitasi:
779. K-th Symbol in Grammar. Bu yerda men yozgan algorithm belgilangan vaqtda hamma testlarni bajara olmadi.

95. Unique Binary Search Trees II. Bunisida esa yechimini hali ham qidirmoqdaman.

Bu uchta masalaning yechimlarini topdingizmi?
🤯3😁1
🇬🇧 400 problems solved on LeetCode! Yeah! 😬🥳

🇺🇿 400ta masalani yechdim! Siiiuuu! 😬🥳
🔥19😁3❤1
🔥20👏4
🇺🇿Foydali odat

Bugun qanday qilib LeetCode-dagi masalalarni har kuni yechishni odatga aylantirish mumkinligi haqida yozmoqchiman.

Bu haqida o'ylasam 3ta technique hayolimga keladi:

1. Kamdan boshlash.📈
Odat kiritish uchun kamdan boshlang. Har kuni 15 daqiqa, yoki 20 daqiqa, yoki 30 daqiqa ajrating. Yoki eng oson masalalardan boshlang va har kuni 1ta masaladan yechishni maqsad qilib qo’ying.

2. Mental energy yoki will power.✨
Ertalab turganingizda sizda mental energy hajmi ko’p bo’ladi. Qandaydir yangi yoki qiyin ish bo’lsa, uni birinchi o’rinda bajarishga harakat qiling.

3. Trigger. 👨‍💻
❌ Yomon triggerlardan voz keching.
Masalan, ertalab turganda telefonni tekshirish. Bu narsa mental energy-ni va vaqtingizni olib qo’yadi. Qanday qilib voz kechsa bo’ladi? Telefonni tovushsiz mode-ga qo’ying, internetni o’chiring va o’zingizdan uzoqqa qo’ying.

✅ Yaxshi triggerlarni yarating.
Masalan, ertalab turganinggizda kompyuterni to’g’risiga o’tirib, uni qo’shing. Bu narsa sizni masala yechishga trigger qiladi.

Foydali bo’ladi deb umid qilaman.🙂
#nocode
👍26🔥3
🇬🇧Recursion: Recap

Hi, guys! Today is the weekend🙌, so let's do a recap of Recursion topic. I've prepared one easy task and one medium task for you.

🟢 Easy problem: 501. Find Mode in Binary Search Tree
You can check my solution here: Java Solution using DFS and Map

🟡 Medium task: 102. Binary Tree Level Order Traversal
My solution: Java | in just 1 ms

Hope you are enjoying your weekend and not forgetting about daily coding😄😬
❤2👍2
🇺🇿Rekursiya: Takrorlash

Hammaga salom! Bugun dam olish kuni bo'lganligi uchun yangi mavzu bo'lmaydi🙌. Keling Rekursiya mavzusini takrorlaymiz.
Men sizlarga bitta oson va bitta o'rta qiyinlik darajadagi masalalarni tayyorladim.

🟢 Oson masala: 501. Find Mode in Binary Search Tree
Men yozgan yechim: Java Solution using DFS and Map

🟡 O'rta qiyinlik darajadagi masala: 102. Binary Tree Level Order Traversal
Mening yechimim: Java | in just 1 ms

Umid qilamanki dam olish kuningiz xayrli o'tmoqda. Har kuni code yozish haqida unutmang😄😬
🔥4❤1😁1
🇬🇧Hashtable

Hi, guys! I think we covered Binary trees and Recursion well enough to be able to solve problems on LeetCode. Let's start another topic today - Hashtable. I chose this topic because it was the second most voted choice in the poll. I'll leave a link to short article about hashtables as a data structure: baeldung.

I think we should start from practice before diving into theory. Let's go and crack those problems related to hashtables!

🟢 Easy one: 219. Contains Duplicate II
👨‍💻 My solution: Java 3 Approaches To One Solution | From 8% to 70%

🟡 Medium one: 981. Time Based Key-Value Store
👨‍💻 My solution: Java Solution Using TreeMap

No worries. We will cover theoretical part as well😁
🔥2
🇺🇿Hashtable

Hammaga salom! Binar daraxtlar va Rekursiya mavzularini LeetCode-da masalalarni yechib boshlash uchun yetarli darajada o'tdik deb o'ylayman. Bugun boshqa katta va qiziq mavzuni boshlayman - Hashtable. So'rovnomada bu eng ko'p ovoz yig'gan mavzulardan ikkinchisi edi - havola.

Hozircha, Hashtable mavzusida bugun hech qanday nazariy ma'lumot bo'lmaydi. Faqat Hashtable ma'lumot tuzilmasi (data structure) haqida qisqa maqolaga havola qoldiraman: baeldung.

Menimcha, amaliyotdan boshlab, keyin nazariya o'tganimiz samaraliroq bo'ladi. Shuning uchun sizlarga ikkita masala tayyorlab qo'ydim.

🟢 Oson: 219. Contains Duplicate II
👨‍💻 Mening yechimim: Java 3 Approaches To One Solution | From 8% to 70%

🟡 O'rtacha qiyin: 981. Time Based Key-Value Store
👨‍💻 Mening yechimim: Java Solution Using TreeMap

Xavotir olmang, keyingi postlarda nazariya ham bo'ladi 😁
👍4👎1