LeetCodin
1000+ Solved problems | Yechilgan masalalar |🇺🇿|🇬🇧 - Data Structures and Algorithms | Ma'lumotlar tuzilmalari va Algoritmlar - SE at Deloitte, USA LinkedIn: linkedin.com/in/bekhzod-tairov LeetCode: https://leetcode.com/tbekpro/
إظهار المزيد- المشتركون
- التغطية البريدية
- ER - نسبة المشاركة
جاري تحميل البيانات...
جاري تحميل البيانات...
Can you solve this real interview question? Trim a Binary Search Tree - Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It can be proven that there is a unique answer. Return the root of the trimmed binary search tree. Note that the root may change depending on the given bounds. Example 1: [
https://assets.leetcode.com/uploads/2020/09/09/trim1.jpg]Input: root = [1,0,2], low = 1, high = 2 Output: [1,null,2] Example 2: [
https://assets.leetcode.com/uploads/2020/09/09/trim2.jpg]Input: root = [3,0,4,null,2,null,null,1], low = 1, high = 3 Output: [3,2,null,1] Constraints: * The number of nodes in the tree is in the range [1, 104]. * 0 <= Node.val <= 104 * The value of each node in the tree is unique. * root is guaranteed to be a…
Can you solve this real interview question? Trim a Binary Search Tree - Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all its elements lies in [low, high]. Trimming the tree should not change the relative structure of the elements that will remain in the tree (i.e., any node's descendant should remain a descendant). It can be proven that there is a unique answer. Return the root of the trimmed binary search tree. Note that the root may change depending on the given bounds. Example 1: [
https://assets.leetcode.com/uploads/2020/09/09/trim1.jpg]Input: root = [1,0,2], low = 1, high = 2 Output: [1,null,2] Example 2: [
https://assets.leetcode.com/uploads/2020/09/09/trim2.jpg]Input: root = [3,0,4,null,2,null,null,1], low = 1, high = 3 Output: [3,2,null,1] Constraints: * The number of nodes in the tree is in the range [1, 104]. * 0 <= Node.val <= 104 * The value of each node in the tree is unique. * root is guaranteed to be a…
🇺🇿 Binary Tree: Inorder Traversal (Inorder aylanib o'tish usuli) Hammaga salom! Kecha so'rovnomaga bergan javoblaringiz uchun rahmat. Ko'rinib turibdiki, barcha ma'lumotlar tuzilmalari ko'rib chiqilishi kerak va biz Binary Tree-dan boshlaymiz, chunki bu top tanlov edi. Umid qilamanki, bir kun biz ushbu ma'lumotlar tuzilmasini onlayn tarzda to'liq ko'rib chiqamiz, chunki buning uchun men avval yaxshilab tayyorlanishim kerak. Bugun esa men sizning e'tiboringizni Ikki tugunli (Binary Tree) daraxtning Inorder aylanib o'tish usuliga qaratmoqchiman. Inorder usuli bilan daraxtni kesib o'tishning asosiy g'oyasi: 1. Chap tugunga o'ting (chap bola daraxt) 2. Keyin ona tugunga [parent node] boring 3. Keyin o'ng tugunga (o'ng bola daraxt) o'ting. [Agar noto'g'ri tarjima qilgan bo'lsam, iltimos, comment qilib yozib yuboring🙈] Keling, shu yerda to'xtab, yuqoridagi ma'lumotlarni bilib turib, LeetCode-dagi masalani yechishga harakat qilamiz: 94. Ikkilik daraxtning inorder tartibida o'tish Maslahat: rekursiv usuldan foydalanib…
🇬🇧Binary Tree: Inorder Traversal 🇺🇿O'zbekchasi pastda⬇️ Hi, guys! Thanks for your answers to the poll I shared yesterday. It's obvious that all data structures need to be overviewed and we will start from Binary Tree since it was the top choice. I hope that one day we will fully review this data structure online later. Today I want to draw your attention to Inorder Traversal of Binary Tree. Basic idea of inorder traversal is: 1. Go to the left node (subtree) 2. Then go to the parent 3. Then go to the right node (subtree). Let's pause here. Try to solve the problem on LeetCode just knowing the information above: 94. Binary Tree Inorder Traversal Hint: try to use recursive method. OK. I hope you were able to solve it. Here is more information on inorder traversal: 1. Article about inorder traversing 2. My solution on LeetCode. I'll add animated image to demonstrate how a binary tree should be traversed.
تسمح خطتك الحالية بتحليلات لما لا يزيد عن 5 قنوات. للحصول على المزيد، يُرجى اختيار خطة مختلفة.