Leetcode 236 Lowest Common Ancestor of a Binary Tree

Introduction Daniel (🧔🏽‍♂️) nodded his head slowly as he added cream to his freshly poured coffee. He had worked hard to learn his Leetcode and he was feeling ready. He took a sip and walked over to his laptop and sat down. Moments later the interview began. 👩 “Good afternoon Daniel! Thanks for taking the time to interview with me today. Let’s begin with some brief introductions. My name is Jordanna!...

January 7, 2023 · 9 min · 1821 words · Me

Leetcode 121 Best Time to Buy and Sell Stock

Problem statement You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. Example 1: Input: prices = [7,1,5,3,6,4] Output: 5 Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5....

January 2, 2023 · 2 min · 220 words · Me

Leetcode 1 Two Sum

Introduction After weeks of preparation, the big day has finally arrived. At 10:28 am PST, Javier (👨) is moments away from his first interview with Jordanna (👩), a senior software engineer at MAANG inc. The zoom call begins. 👩 “Thanks for taking the time to interview with us today. We’ll start off with brief introductions. My name is Jordanna and I earned my M.Sc. from UPenn before joining MAANG six years ago....

January 2, 2023 · 5 min · 943 words · Me

Leetcode 208 Implement Trie

Problem Statement A trie (pronounced as “try”) or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: Trie() Initializes the trie object. void insert(String word) Inserts the string word into the trie. boolean search(String word) Returns true if the string word is in the trie (i....

December 19, 2022 · 3 min · 467 words · Me

Leetcode 278 First Bad Version

Problem Statement You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad....

December 13, 2022 · 2 min · 235 words · Me