snippets

Snippet code, help with coding code samples, solution to interview questions in Python Java, PHP etc.

Leetcode 146. LRU Cache: Multiple Solutions in Python Code

“Design LRU cache” is a very typical interview problem asked in FAANG. This question shows the design capability of the candidate and how he selects the datatype while programming. Caches are an integral component of any computing system. These are tiny containers that store data fragments to make them accessible easily thus, reducing computing time.  …

Leetcode 146. LRU Cache: Multiple Solutions in Python Code Read More »

Leetcode: Count Good Nodes in Binary Tree in Python

Count good nodes in a binary tree, according to LeatCode this is Microsoft’s most asked interview question of 2021 so far.  I think it’s a pretty good problem to understand. A lot of basic Tree fundamental knowledge can be gained from this problem.  So we’re given the root of a binary tree that is going …

Leetcode: Count Good Nodes in Binary Tree in Python Read More »

What is the best way to sort Python dictionary by Value

Data structure dictionary in Python before 3.7 version has no particular order, which makes the process of sorting a tedious job for most beginners Sorting data is not a new thing for us. We perform this operation as we buy products online, set official and unofficial appointments, or simply stack our wearables in a wardrobe. …

What is the best way to sort Python dictionary by Value Read More »

Leetcode 1: Two Sum problem – Multiple Solutions in Python

Two Sum problem is considered easy and is frequently asked in Amazon phone interviews. We will see how we can start with a brute force solution and try to improve the code by introducing more data structures. Problem Statement: Given an array of integers nums and an integer target return indices of the two numbers …

Leetcode 1: Two Sum problem – Multiple Solutions in Python Read More »

Generate Random Number and String in Python

Generate Random Number and String in Python

Creating random number or string in Python is way more easier then you think. random module can be used to generate random numbers in Python. Combining String module with random module, we can generate random strings in Python. I have tried these two modules myself in multiple programs to generate random numbers and strings. we …

Generate Random Number and String in Python Read More »

Scroll to Top