Photo by Daniele Levis Pelusi on Unsplash

Python has three Jump operators which can move the program control from one place to another. In this blog, we go through these three jump operators.

Pass — The pass acts as a placeholder, a syntactic sugar. Whenever the python interpreter encounters pass it does nothing. This feature allows the enclosing construct to be a valid one.

Continue — The continue operator ignores every code (following the pass statement) in the innermost loop and continues the next iteration of the loop

Break — The break operator breaks out of the innermost enclosing loop.

Let us see the use of three…


Photo by Daniel Gregoire on Unsplash

SSM Run command on multiple hosts in parallel without SSH

Recently due to some updates from our security team, we had to install an agent on all our hosts in the AWS account. We run 1100+ EC2 instances in our account. These servers have varied OS (Amazon Linux, Fedora, CentOS, RHEL, Ubuntu, Windows, FreeBSD, etc. Also, these servers power various workloads like EMR (various versions), EKS, ECS, Airflow, Tableau, Alation. Many of these are vendor configured servers that have their own AMIs. Creating AMIs for each type with the agent would have taken a long time and a huge effort…


Photo by Benjamin Child on Unsplash

In this blog, we will go through a medium-tagged question. This question is frequently asked in interviews for Amazon & Facebook.

253. Meeting Rooms II

Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.

Example:

Input: intervals = [[9,10],[4,9],[5,17]]
Output: 2

Approach:

We need to find how many concurrent meetings are happening. Once we have that info we can find the no of meeting rooms required. To find the concurrent meetings at any given time we need to know how many meetings’ start and end time covers that.

We can do a brute-force…


Photo by Michal Matlon on Unsplash

Today’s question is from Daily Leetcode Coding Challenge — May Edition. It is a medium-tagged question. Let us look into the problem statement.

150. Evaluate Reverse Polish Notation

Evaluate the value of an arithmetic expression in Reverse Polish Notation.

Valid operators are +, -, *, and /. Each operand may be an integer or another expression.

Note that the division between two integers should truncate toward zero.

Example:

Input: tokens = ["2","1","+","3","*"]
Output: 9
Explanation: ((2 + 1) * 3) = 9

Understanding the problem:

From the above example, we understand that the last two elements become operand whenever we encounter an operator. Also, once we have computed the…


Photo by Clark Van Der Beken on Unsplash

Today’s question is from Daily Leetcode Coding Challenge — May Edition. It is a medium-tagged question. Let us look into the problem statement.

890. Find and Replace Pattern

Given a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order.

A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word.

Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no…


Photo by Camille Minouflet on Unsplash

Today’s question is from Daily Leetcode Coding Challenge — May Edition. It is a medium-tagged question. Let us look into the problem statement.

102. Binary Tree Level Order Traversal

Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).

Example:

Input: root = [3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]

Understanding the Problem:

Level order traversal is similar to BFS. We process all nodes at a level before we move on to the next level. In other words, first, we cover all grandparents, then all parents then all children.


Photo by Clay Banks on Unsplash

Today’s question is from Daily Leetcode Coding Challenge — May Edition. It is a medium-tagged question. Let us look into the problem statement.

462. Minimum Moves to Equal Array Elements II

Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.

In one move, you can increment or decrement an element of the array by 1.

Example:

Input: nums = [1,2,3]
Output: 2

We can make all number equal to a number. That number can be maximum number of the list or minimum number of that list. It can be also be a median. …


Photo by Thiébaud Faix on Unsplash

Today’s question is from Daily Leetcode Coding Challenge — May Edition. It is a medium-tagged question. Let us look into the problem statement.

609. Find Duplicate File in System

Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms of their paths. You may return the answer in any order.

A group of duplicate files consists of at least two files that have the same content.

A single directory info string in the input list has the following format:

  • "root/d1/d2/.../dm f1.txt(f1_content) f2.txt(f2_content) ... fn.txt(fn_content)"

It…


Photo by Mike Alonzo on Unsplash

Today’s question is from Daily Leetcode Coding Challenge — May Edition. It is a medium-tagged question. Let us look into the problem statement.

1048. Longest String Chain

Given a list of words, each word consists of English lowercase letters.

Let’s say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2. For example, "abc" is a predecessor of "abac".

A word chain is a sequence of words [word_1, word_2, ..., …


Photo by Rishabh Varshney on Unsplash

Today’s question is from Daily Leetcode Coding Challenge — May Edition. It is a hard-tagged question. Let us look into the problem statement.

968. Binary Tree Cameras

Given a binary tree, we install cameras on the nodes of the tree.

Each camera at a node can monitor its parent, itself, and its immediate children.

Calculate the minimum number of cameras needed to monitor all nodes of the tree.

Example:

Input: [0,0,null,0,0]
Output: 1
Explanation: One camera is enough to monitor all nodes if placed as shown.

Understanding the problem:

Since we want to minimize the number of cameras, one thing is clear we don't place…

Amit Singh Rathore

Cloud | ML | Big Data

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store