<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Interview Bits]]></title><description><![CDATA[Know how the things work around and become the best of the best.]]></description><link>https://interviewbits.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 22 Oct 2026 01:02:29 GMT</lastBuildDate><atom:link href="https://interviewbits.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Constructing a Binary Tree from Preorder and Inorder Traversal]]></title><description><![CDATA[Construct a binary tree from preorder and inorder traversal arrays using Python. Learn the method and view example illustrations]]></description><link>https://interviewbits.hashnode.dev/constructing-a-binary-tree-from-preorder-and-inorder-traversal</link><guid isPermaLink="true">https://interviewbits.hashnode.dev/constructing-a-binary-tree-from-preorder-and-inorder-traversal</guid><category><![CDATA[Python]]></category><category><![CDATA[Tree]]></category><category><![CDATA[Binary Search Algorithm]]></category><category><![CDATA[coding]]></category><category><![CDATA[leetcode]]></category><category><![CDATA[leetcode-solution]]></category><dc:creator><![CDATA[Ayush Thakur]]></dc:creator><pubDate>Mon, 15 Jul 2024 03:38:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/cvBBO4PzWPg/upload/efe78e5b9ecb432a63cbd62d1fd3b125.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One of the fascinating challenges in binary tree problems is reconstructing the tree from its traversal data. In this post, we will discuss how to construct a binary tree given the preorder and inorder traversal arrays.</p>
<h4 id="heading-problem-statement">Problem Statement</h4>
<p>Given two integer arrays, <code>preorder</code> and <code>inorder</code>, where:</p>
<ul>
<li><p><code>preorder</code> is the preorder traversal of a binary tree.</p>
</li>
<li><p><code>inorder</code> is the inorder traversal of the same tree.</p>
</li>
</ul>
<p>Our goal is to construct and return the binary tree.</p>
<p><strong>Example 1:</strong></p>
<ul>
<li><p><strong>Input:</strong> <code>preorder = [3,9,20,15,7]</code>, <code>inorder = [9,3,15,20,7]</code></p>
</li>
<li><p><strong>Output:</strong> <code>[3,9,20,null,null,15,7]</code></p>
</li>
</ul>
<p><strong>Example 2:</strong></p>
<ul>
<li><p><strong>Input:</strong> <code>preorder = [-1]</code>, <code>inorder = [-1]</code></p>
</li>
<li><p><strong>Output:</strong> <code>[-1]</code></p>
</li>
</ul>
<p><strong>Constraints:</strong></p>
<ol>
<li><p><code>1 &lt;= preorder.length &lt;= 3000</code></p>
</li>
<li><p><code>inorder.length == preorder.length</code></p>
</li>
<li><p><code>-3000 &lt;= preorder[i], inorder[i] &lt;= 3000</code></p>
</li>
<li><p><code>preorder</code> and <code>inorder</code> consist of unique values.</p>
</li>
<li><p>Each value of <code>inorder</code> also appears in <code>preorder</code>.</p>
</li>
<li><p><code>preorder</code> is guaranteed to be the preorder traversal of the tree.</p>
</li>
<li><p><code>inorder</code> is guaranteed to be the inorder traversal of the tree.</p>
</li>
</ol>
<h4 id="heading-approach">Approach</h4>
<p>To solve this problem, we will leverage the properties of preorder and inorder traversals:</p>
<ol>
<li><p><strong>Preorder Traversal (Root, Left, Right)</strong>:</p>
<ul>
<li>The first element is always the root of the tree/subtree.</li>
</ul>
</li>
<li><p><strong>Inorder Traversal (Left, Root, Right)</strong>:</p>
<ul>
<li>The elements are ordered such that the root splits the list into the left subtree and right subtree.</li>
</ul>
</li>
</ol>
<p><strong>Steps to Construct the Tree</strong>:</p>
<ol>
<li><p>Identify the root from the first element of the preorder list.</p>
</li>
<li><p>Locate the root in the inorder list to split it into left and right subtrees.</p>
</li>
<li><p>Recursively repeat the process for the left and right subtrees using the respective preorder and inorder sublists.</p>
</li>
</ol>
<h4 id="heading-complexity-analysis">Complexity Analysis</h4>
<ul>
<li><p><strong>Time Complexity</strong>: The time complexity is (O(n^2)) in the worst case because finding the root in the inorder list takes (O(n)) time, and this process is repeated for each node.</p>
</li>
<li><p><strong>Space Complexity</strong>: The space complexity is (O(n)) for the recursion stack in the worst case (skewed tree) and (O(n)) for storing the lists, although this could be optimized with additional index variables.</p>
</li>
</ul>
<h4 id="heading-implementation">Implementation</h4>
<p>Here's the Python implementation of the above approach:</p>
<pre><code class="lang-python"><span class="hljs-comment"># Definition for a binary tree node.</span>
<span class="hljs-comment"># class TreeNode:</span>
<span class="hljs-comment">#     def __init__(self, val=0, left=None, right=None):</span>
<span class="hljs-comment">#         self.val = val</span>
<span class="hljs-comment">#         self.left = left</span>
<span class="hljs-comment">#         self.right = right</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Solution</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">buildTree</span>(<span class="hljs-params">self, preorder: List[int], inorder: List[int]</span>) -&gt; Optional[TreeNode]:</span>
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> preorder <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> inorder:
            <span class="hljs-keyword">return</span> <span class="hljs-literal">None</span>

        <span class="hljs-comment"># The first element in preorder is the root</span>
        root = TreeNode(preorder[<span class="hljs-number">0</span>])
        <span class="hljs-comment"># Find the root in the inorder list to split left and right subtrees</span>
        mid = inorder.index(preorder[<span class="hljs-number">0</span>])

        <span class="hljs-comment"># Recursively build the left and right subtrees</span>
        root.left = self.buildTree(preorder[<span class="hljs-number">1</span>:mid+<span class="hljs-number">1</span>], inorder[:mid])
        root.right = self.buildTree(preorder[mid+<span class="hljs-number">1</span>:], inorder[mid+<span class="hljs-number">1</span>:])

        <span class="hljs-keyword">return</span> root
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Wanna Be a Big-Shot Researcher? Here's How to Get Noticed! 🔥]]></title><description><![CDATA[Stand out in academia with insider tips on becoming a recognized researcher and thought leader.]]></description><link>https://interviewbits.hashnode.dev/wanna-be-a-big-shot-researcher-heres-how-to-get-noticed</link><guid isPermaLink="true">https://interviewbits.hashnode.dev/wanna-be-a-big-shot-researcher-heres-how-to-get-noticed</guid><category><![CDATA[education]]></category><category><![CDATA[research]]></category><category><![CDATA[psychology]]></category><category><![CDATA[tricks]]></category><category><![CDATA[skills]]></category><category><![CDATA[technology]]></category><dc:creator><![CDATA[Ayush Thakur]]></dc:creator><pubDate>Mon, 13 May 2024 18:05:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/t3zrEm88ehc/upload/cc4739130a1be41ad042268c27dbcba6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let's be real, folks – the world of academia and research can be a jungle 🌴where only the fittest survive. You've got all these big-name professors and hotshot researchers hogging the spotlight, leaving the rest of us mere mortals to fight for the scraps of attention. 😩 But fear not, my friends! <a class="user-mention" href="https://hashnode.com/@ayushthakur02">Ayush Thakur</a> is here to share some insider tips on how you can stand out from the herd and establish yourself as a bona fide thought leader in your field. 💪</p>
<p>First things first, you gotta have the goods. 💯 Nobody's gonna take you seriously if you're peddling half-baked ideas or regurgitating the same old junk everyone else is spewing. You need to bring something fresh and insightful to the table – a unique perspective, a groundbreaking theory, or some jaw-dropping research findings that'll make people sit up and take notice. 🤯</p>
<p>Now, here's where the psychological stuff comes into play. It's not enough to just do good work; you gotta know how to sell it, too. And let me tell you, academics can be a tough crowd to impress. 😑 They're like a bunch of grumpy old coots who've seen it all before, and they ain't gonna give you the time of day unless you really knock their socks off. 🧦</p>
<p>So, how do you grab their attention? Well, my friend, you gotta hustle. 💨 Start by getting your work published in reputable journals and presenting at conferences. But don't just show up and read your paper like a robot – you gotta work the room, schmooze with the bigwigs, and make connections. 🤝 Heck, you might even have to resort to a little shameless self-promotion (within reason, of course). 😏</p>
<p>And speaking of self-promotion, you better believe social media is your new best friend. 💻 Twitter, LinkedIn, <a target="_blank" href="http://academia.edu">academia.edu</a> – you name it, you gotta be on it. Share your work, engage with other researchers, and don't be afraid to toot your own horn a little (just don't go overboard and become that obnoxious guy nobody wants to follow). 🎺</p>
<p>Another trick is to collaborate with other researchers, especially those who are already well-established in your field. 🤝 Not only will you get to learn from the best, but you'll also bask in their reflected glory. It's like when a hot celebrity 🔥 starts dating an unknown schlub – suddenly, everyone's like, "Who's that guy?" and boom, the schlub's a household name. 🌟</p>
<p>Finally, remember that becoming a thought leader isn't just about the work you do; it's about the persona you project. 💅 You gotta come across as an authority, someone who knows their stuff inside and out. So, brush up on your public speaking skills, learn how to hold your own in debates and discussions, and always, always act like you belong at the grown-ups' table. 🍷</p>
<p>Look, I ain't gonna lie to you – establishing yourself as a thought leader in research fields ain't gonna be a cakewalk. 🥵 It's gonna take hard work, perseverance, and a whole lot of shameless self-promotion. But if you follow these tips and stay true to yourself (and your research), you just might find yourself rubbing elbows with the big dogs before you know it. 🐕‍🦺</p>
<p>Now, go forth and conquer, my friends! 💥 And if you ever need a pep talk or a shoulder to cry on, your old pal <a class="user-mention" href="https://hashnode.com/@ayushthakur02">Ayush Thakur</a> will always be here for you. 🤗</p>
]]></content:encoded></item><item><title><![CDATA[How to Handle Non-Constructive Feedback from a Coworker]]></title><description><![CDATA[Learn how to handle non-constructive feedback gracefully. Stay calm, seek clarification, and focus on actionable insights for growth]]></description><link>https://interviewbits.hashnode.dev/how-to-handle-non-constructive-feedback-from-a-coworker</link><guid isPermaLink="true">https://interviewbits.hashnode.dev/how-to-handle-non-constructive-feedback-from-a-coworker</guid><category><![CDATA[management]]></category><category><![CDATA[communication]]></category><category><![CDATA[community]]></category><category><![CDATA[office]]></category><category><![CDATA[insights]]></category><category><![CDATA[psychology]]></category><category><![CDATA[Feedback]]></category><category><![CDATA[workflow]]></category><dc:creator><![CDATA[Ayush Thakur]]></dc:creator><pubDate>Fri, 10 May 2024 07:34:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/mv38TB_Ljj8/upload/ebd93601c5ebe33fb02603cc818bcd44.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hey there, my fellow humans! 👋 Have you ever found yourself in one of those cringe-worthy situations where your colleague's feedback just doesn't seem to hit the mark? 🤔 You know, the kind of feedback that leaves you feeling more confused, frustrated, and maybe even a little bit hurt than enlightened? 😖 Yep, we've all been there, and it's not a fun place to be.</p>
<p>It can be such a bummer 😩 when you're working your butt off, putting in the hard yards, and then someone comes along and gives you feedback that's more like a verbal punch in the gut than a constructive critique. 🥊 But fear not, my friends! 🙌 I'm here to share some tried and true tips on how to handle those not-so-helpful feedback situations, with a little psychological insight sprinkled in for good measure. 🧠</p>
<p>First things first, let's talk about the psychology behind it all. When we receive feedback, our brains tend to go into self-defense mode. 🛡️ We get a little defensive, and our ego starts to feel threatened. It's a natural human response, and it's totally understandable. But the key is to try and step back and look at the feedback objectively, without letting your emotions take over. 😌</p>
<p>I know, I know, easier said than done, right? 😅 But trust me, it's worth the effort. When you can approach the feedback with a more level-headed mindset, you open yourself up to the possibility of actually learning something, even if the delivery wasn't exactly what you were hoping for. 🤓</p>
<p>Now, I know what you're thinking – "But how can I be objective when the feedback is just plain unhelpful?" 🤷‍♀️ Well, that's where the magic happens, my friends. Instead of getting all riled up and firing back a snarky response, try to take a deep breath and ask yourself, "What can I learn from this, even if the delivery wasn't great?" 🤔</p>
<p>One thing you could try is to ask your colleague for clarification. Say something like, "I really appreciate you taking the time to provide feedback, but I'm a little unsure about what exactly you're suggesting I do differently. Could you please elaborate a bit more? 🙏" This not only shows that you're open to the feedback, but it also gives you a chance to get a better understanding of what they're trying to say.</p>
<p>Another helpful strategy is to focus on the specific areas of the feedback that you can actually use. Even if the overall feedback isn't as constructive as you'd like, there might be one or two nuggets of wisdom that you can take and apply to your work. 💡 Hone in on those and let the rest go.</p>
<p>And remember, sometimes the problem isn't with the feedback itself, but with the way it's being delivered. If your colleague has a tendency to be a little blunt or even a tad harsh, try to keep that in mind and not take it too personally. 😌 Easier said than done, I know, but it can really help to put things in perspective.</p>
<p>At the end of the day, the goal is to turn that not-so-helpful feedback into something you can actually use to improve and grow. 🌱 It might take a little extra effort, a whole lot of patience, and maybe even a few deep breaths, but trust me, it's worth it. You've got this, my friends! 💪</p>
<p>So, the next time you find yourself on the receiving end of some less-than-stellar feedback, remember to stay calm, ask for clarification, and focus on the bits that you can actually use. 📝 And who knows, you might just end up surprising yourself with how much you can learn, even from the most unhelpful of feedback. 🤯</p>
]]></content:encoded></item></channel></rss>