Found 33676 Articles for Programming

Minimum circular rotations to obtain a given numeric string by avoiding a set of given strings

Shubham Vora
Updated on 25-Aug-2023 15:59:09

160 Views

In this problem, we will find the number of rotations required to achieve the target string from the string containing N 0s. Also, we will skip the strings given in the array while making rotations. We can use the BFS algorithm to find the minimum rotations required to get the target string. Problem Statement We have given a target string containing the N numeric characters. Also, we have given the strs[] array containing the M strings of size N containing the numeric characters. We need to initially achieve the target string from a string containing N 0's by performing the ... Read More

Implementing Water Supply Problem using Breadth First Search

Shubham Vora
Updated on 25-Aug-2023 15:57:37

209 Views

In this problem, we will find the maximum number of cities to which we can supply water. We can consider this problem as a graph traversing the blocked node. So, we can use the breadth-first search algorithm to find the maximum number of connected cities. Problem Statement We have given the total N cities. Also, we have given an edge between two cities; all cities are connected with any other single or multiple cities. We need to set up the water supply connection in each city. We have also given the blocked[] array containing the 0 and 1 values. ... Read More

Find integral points with minimum distance from given set of integers using BFS

Shubham Vora
Updated on 25-Aug-2023 15:56:00

109 Views

In this problem, we will find the K points which are nearest to any of the given points from the points given in the array. To find the points which are nearest to the given points, we can take the nums[p] + 1 or nums[p] -1 for each element of the array if it is not present in the array. If we require more points, we can take the nums[p] + 2 or nums[p] – 2 points, and so on. Problem Statement We have given a nums[] array containing the N positive and negative integers. Each point of ... Read More

Clockwise Triangular traversal of a Binary Tree

Shubham Vora
Updated on 25-Aug-2023 15:54:54

264 Views

In this problem, we will create a complete binary tree and traverse it in a circular clockwise direction. For the clockwise traversal, we can think of traversing the boundaries of the tree. For example, we can traverse the outer boundary of the tree first. After that, we can remove visited nodes and traverse the inner boundary of the tree. In this way, we need to make min(height/2, width/2) traversal of the given binary tree. Problem Statement We have given a complete binary tree containing N nodes and need to traverse it in a clockwise direction. Sample Examples Input n ... Read More

Check if the Left View of the given tree is sorted or not

Shubham Vora
Updated on 25-Aug-2023 15:53:45

148 Views

In this problem, we will check whether the left view of the binary tree is sorted. The left view of the binary tree means nodes we can see when we look at the binary tree from the left side. In simple terms, we can see only the first node of each level. So, we need to extract the value of the first node and check whether they are sorted to get the output. Problem Statement We have given a binary tree. We need to print whether the binary tree's left view is sorted. If it is sorted, print 'Yes'. ... Read More

Check if cells numbered 1 to K in a grid can be connected after removal of atmost one blocked cell

Shubham Vora
Updated on 25-Aug-2023 15:52:11

98 Views

In this problem, we will check whether we can connect all K cells by unblocking any single cell. To solve the problem, we will assume all connected K as a single Island. If any single blocked cell can connect all Island of the matrix, it is only possible to connect all K cells of the matrix. So, If the matrix contains more than 4 Island, it is not possible to connect all cells. Problem Statement We have given a mat[] matrix of size n*m. We have also given a positive integer, K. The matrix contains 0 and -1 in ... Read More

Boundary Level order traversal of a Binary Tree

Shubham Vora
Updated on 25-Aug-2023 15:49:41

240 Views

In this problem, we will traverse each boundary of the given binary tree in the given order. We will use the recursive approach to traverse each boundary of the binary tree one by one. However, we will also learn the iterative approach using a stack to traverse the binary tree's boundary and increase the code's performance. Problem Statement We have given a binary tree, and we need to traverse each boundary of the tree in the given order. Traverse left boundary in top to bottom manner. Traverse bottom boundary from left to right. Traverse the right boundary from bottom ... Read More

Python – Check for float String

Pranavnath
Updated on 25-Aug-2023 16:06:02

753 Views

The strings consist of characters and to transform them into float data type, Python facilitates us with various methods using the inbuilt function. With the help of these inbuilt functions, we can check for the float strings easily. In this article, the user will learn how to check whether a string contains a float value. To achieve this, three strategies are demonstrated to verify float string. Isdigit() method is also used to check if the given string has only digits. Then the count() and replace() are used to check if the string contains decimal values and other characters of the ... Read More

Blackman in Python Numpy

Pranavnath
Updated on 25-Aug-2023 15:58:19

381 Views

Introduction In signal processing and spectral analysis, window functions play a vital part in forming and modifying signals. The Blackman window is a commonly utilized window function in signal processing that makes a difference decrease spectral leakage effects. It is actualized in Python utilizing the effective NumPy library, which gives effective cluster operations and scientific capacities. In this article, we'll investigate three distinctive examples to execute the Blackman window in Python using the powerful NumPy library. Each approach will be went with by detailed calculations, step-by-step clarifications, of the Python syntax, and code cases with their respective outputs. Blackman ... Read More

How to Append suffix/prefix to strings in a Python list?

Pranavnath
Updated on 25-Aug-2023 15:55:21

2K+ Views

Introduction In this article, the users will understand how to append suffix/prefix to strings in a Python list. A List would store elements of different data types within these “[]” brackets. The string manipulation would be possible in the Python language. Various inbuilt string method are available in Python to append suffix/prefix to strings in a Python list like reduce(), map(), and so on. The two approaches are demonstrated in the article to append the specified character either in the starting or the rear side to the string. The methods to do this can be varying and some may be ... Read More

Advertisements