Append Suffix and 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

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

Convert Binary to ASCII Character String

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

566 Views

In this problem, we need to convert the binary string to the character string. We can convert the binary string to an ASCII number string first, and then we can convert the character string. Problem statement – We have given a binary string bin_str whose size is multiple of 8. We need to convert the binary string to the character string. Sample examples Input bin_str = "0110110001101010" Output 'lj' Explanation – The ‘01101100’ is equivalent to 108 in the decimal, which is equivalent to the ASCII value of the ‘l’. The ‘01101010’ equals 106, and ... Read More

Check Connection of Cells in a Grid After Removing Blocked Cell

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

97 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

Aggregate Values by Tuple Keys in Python

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

359 Views

Introduction In the current world, handling data is the most challenging task for organizations with a high volume of data and with the development of data science and machine learning it has become easier to access. And the Python language plays a vital role in dealing with this data, as the data present can be relevant or irrelevant to each other. When they have some relevancy, it can be stored combinable with the other data or simply the aggregating of the data. In this, it combines the elements with similar characteristics and attributes they belong to. To do this process, ... Read More

Minimum Number of Insertions to Remove Adjacent Duplicates in String

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

119 Views

In this problem, we will count the minimum number of characters we need to insert to remove all adjacent duplicate characters. To solve the problem, we need to count the total number of adjacent duplicate character pairs. Problem statement – We have given a string named str containing N alphabetical characters. We need to find the total number of different characters we require to add to the string such that the resultant string shouldn’t contain any adjacent duplicated characters. Sample examples Input str = "ccddrt" Output 2 Explanation – We need to insert one character ... Read More

Boundary Level Order Traversal of a Binary Tree

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

239 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

Count of Simple Cycles in an Undirected Graph Having n Vertices

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

429 Views

Introduction Undirected graphs are an essential component of computer science and graph theory, representing a group of nodes connected by edges without any directionality. One common problem associated with undirected graphs is the counting of simple cycles or circuits, which are closed paths that visit each vertex only once. In this article, we will explore how to get total count of the given undirected graph with N vertices using the powerful programming languages C and C++. Undirected Graph Before we jump into coding, let's ensure everyone grasps what constitutes a simple cycle within an undirected graph. Let us consider an ... Read More

DSATUR Algorithm for Graph Coloring

Pranavnath
Updated on 25-Aug-2023 15:45:42

1K+ Views

Introduction Graph coloring may be an essential issue in graph hypothesis. The DSatur algorithm presents a compelling approach to play down the utilization of colors while performing chart coloring. By deliberately selecting vertices with the most noteworthy immersion degree, DSatur guarantees an optimized color task that maximizes color differing qualities and minimizes color utilization. In this article, we explore the DSatur calculation for chart coloring and its utilization utilizing C++. The calculation decides its title from the two key concepts it utilizes: Degree and Submersion. It considers the degrees of the vertices and their inundation degrees, which speak to the ... Read More

Advertisements