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:

Understanding the problem:

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


Photo by Denes Kozma 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.

1354. Construct Target Array With Multiple Sums

You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure :

1. let x be the sum of all elements currently in your array.
2. choose index i, such that 0 <= i < n and set the value of arr at index i to x.
3. You may repeat this procedure as many times as needed.

Return true if it is possible…


Photo by Henry Hustava 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.

1197. Minimum Knight Moves

In an infinite chessboard with coordinates from -infinity to +infinity, you have a knight at square [0, 0].

A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction.

Return the minimum number of steps needed to move the knight to the square [x, y]. It is guaranteed the answer exists.

Example:


Photo by Michael Van Kerckhove 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.

65. Valid Number

A valid number can be split up into these components (in order):

1. A decimal number or an integer.
2.(Optional) An 'e' or 'E', followed by an integer.

A decimal number can be split up into these components (in order):

1. (Optional) A sign character (either '+' or '-').
2. One of the following formats:
3. At least one digit, followed by a dot '.'.
4. At least one digit, followed by a dot '.', followed by at least one…


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

906. Super Palindromes

Let’s say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome.

Given two positive integers left and right represented as strings, return the number of super-palindromes integers in the inclusive range [left, right].

Example:


Photo by Elevate 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.

1564. Put Boxes Into the Warehouse I

You are given two arrays of positive integers, boxes and warehouse, representing the heights of some boxes of unit width and the heights of n rooms in a warehouse respectively. The warehouse's rooms are labeled from 0 to n - 1 from left to right where warehouse[i] (0-indexed) is the height of the ith room.

Boxes are put into the warehouse by the following rules:

  • Boxes cannot be stacked.
  • You can rearrange the insertion order of the…


Photo by Dai Yoshinaga 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.

1423. Maximum Points You Can Obtain from Cards

There are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints.

In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.

Your score is the sum of the points of the cards you have taken.

Given the integer array cardPoints and the integer k, return the maximum…


Photo by Sharon McCutcheon on Unsplash

Problem:

Given an integer n, return the least number of perfect square numbers that sum to n.

A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not.

Approach:

The brute force approach suggests using a recursive function to find all combination of perfect squares which sum to target. Then find the length of the combination which has min length. But that will work only on small numbers. …


Image by author

A quick refresher on SQS Metrics

Before we see the metrics a quick glance at the SQS workflow

  1. The producer sends the message to the SQS queue.
  2. If there is no delay configuration, the message is available(visible) in the queue for all consumers. If we have a delay configuration then the message will stay in the queue in a delayed state and will become visible for the consumer(s) after the delay expires.
  3. Consumers poll the SQS queue for messages. This will return visible messages from the queue. This operation also makes the message to be invisible to consumers.
  4. Once the…


Photo by Christian Stahl on Unsplash

Two are better than one if they act as one.

Two pointer algorithm is one of the most commonly asked questions in any programming interview. This approach optimizes the runtime by utilizing some order (not necessarily sorting) of the data. It is generally applied on lists (arrays) and linked lists. This is generally used to search pairs in a sorted array. This approach works in constant space.

In this technique pointers represent either index or an iteration attribute like node’s next.

Steps in two pointer approach:

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