Found 27104 Articles for Server Side Programming

Python program to concatenate all Elements of a List into a String

Niharika Aitam
Updated on 02-Aug-2023 12:17:23

262 Views

List is one of mutable data structure available in python which is used to store the data of any datatype. It is denoted with the square braces "[]" and all the elements in the list are separated by comma. When we want to access an element from the list, indexing will be applied. In the same way we have the string data structure which is immutable and stores the data in the string datatype. The string is given as double quotes or single quotes. The indexing will be applied to access the elements from the string. Now in this article ... Read More

Python program to compute arithmetic operation from String

Niharika Aitam
Updated on 02-Aug-2023 11:46:33

218 Views

Arithmetic operations are the mathematical calculations on numeric data types. The following are the arithmetic operations allowed in python. Addition (+) Subtraction (-) Multiplication (*) Division (/) Floor Division (//) Modulo (%) Exponentiation (**) There are several ways to compute arithmetic operation from string. Let’s see them one by one. Using the eval() Function The eval() function in Python evaluates an expression passed as a string and returns the result. We can use this function to compute arithmetic operations from a string. Example In this approach, the eval() function evaluates the expression "2 + 3 * 4 - ... Read More

Size of all Connected Non-Empty Cells of a Matrix

Shubham Vora
Updated on 02-Aug-2023 15:59:44

72 Views

In this problem, we will find the size of sets of all non−empty connected cells. We will learn two different approaches for finding the size of all non−empty connected cells of a matrix. In the first approach, we will use the breadth−first search algorithm, and in the second approach, we will use the depth−first search algorithm to traverse the matrix and find the size of all non-empty connected cells. Problem statement − We have given matrix[][] 2D array containing only 0 and 1. Here, 0 represents the empty cell, and 1 represents the non−empty cells. We need to find the ... Read More

Python program to check whether the values of a dictionary are in same order as in a list

Niharika Aitam
Updated on 02-Aug-2023 11:44:29

58 Views

Dictionary is the mutable data structure in python, which allows the user to store the data in the format of key and value. The key and value are separated by using the symbol ":". The keys are unique and the values can be repeated. The values can be given as a single element or multiple elements within a list. If we want to access the elements from a dictionary we have to use the key. It provides various functions and methods to work and manipulate the dictionaries. There are several approaches to check whether the values of a dictionary are ... Read More

Restore a Shuffled Queue as Per given Conditions

Shubham Vora
Updated on 02-Aug-2023 13:55:29

60 Views

In this problem, we have given the persona names and the number of taller people standing in front of that people. We can sort the position of the people according to the number of taller people standing in front of any person. After that, we update the position of each person according to the nums[] array value to get the original queue. Problem statement − We have given an array persons[] and nums[]. The persons[] array contains the person's name, and the nums[] array contains the number of taller people standing in front of each person. This queue is shuffled, ... Read More

Minimum Nodes to be Colored in a Graph such that every Node has a Colored Neighbour

Shubham Vora
Updated on 02-Aug-2023 13:53:47

60 Views

In this problem, we will color the minimum nodes of the graph such that each node of the graph has a colored node at the maximum distance 1. The simple logic to minimize the count of the colored node is that either color the nodes which are at an odd distance or color the nodes at an even distance. So, we can color the alternative node, and for each node, we can have a colored node at most distance 1. Problem statement − We have given a graph containing N nodes and E edges. It is given that we can ... Read More

Python Program to check whether Characters of all string elements are in lexical order or not

Niharika Aitam
Updated on 02-Aug-2023 11:43:59

64 Views

Lexical order refers to the order of characters or strings based on their dictionary or alphabetical order. In lexical order, characters are arranged in the same way they would be in a dictionary. The comparison is done based on the numerical values of the characters in their respective character sets such as ASCII or Unicode. In lexical order, characters are compared based on their ASCII or Unicode values from left to right. The character with a lower ASCII or Unicode value comes before the one with a higher value. For example, in ASCII order, 'a' comes before 'b', 'b' comes ... Read More

PHP Program to Generate the Random Number in the given Range (min, max)

Pradeep Kumar
Updated on 02-Aug-2023 11:39:52

389 Views

What Is PHP ? PHP (Hypertext Preprocessor) is a widely-used open-source scripting language primarily designed for web development. It is a server-side scripting language that is embedded within HTML, allowing developers to create dynamic web pages and interactive web applications. PHP is known for its flexibility, simplicity, and extensive support, making it a popular choice among developers for building robust and scalable websites. It offers a vast range of functionalities and features, including database connectivity, file manipulation, session management, and form handling. PHP code is executed on the server, generating HTML output that is then sent to the client's ... Read More

Minimum Distance from a given Cell to all other Cells of a Matrix

Shubham Vora
Updated on 02-Aug-2023 13:51:23

121 Views

In this problem, we need to find the distance of each cell from the given cell of the matrix. We will use the Breadth−first search traversal to visit each cell of the matrix from the given cell and find the minimum distance for each cell. Problem statement − We have given rows, cols, a, and b positive integers. Here, rows and cols represent the matrix's total number of rows and columns. The a and b is the cell of the matrix. We need to find the minimum distance of each cell of the matrix from the (a, b) cell. ... Read More

Minimum Cost using Dijkstra by Modifying Cost of an Edge

Shubham Vora
Updated on 02-Aug-2023 13:49:54

205 Views

In this problem, we need to find the minimum path from 1 to N using Dijakstra’s algorithm, and we can update the cost of any single edge to cost/2. Here, we will find each node's distance from the source node to the destination node. After that, we will take the shortest distance of node u from the source and node v from the destination and add them with the cost/2 of the u −> v edge. In this way, we will find the minimum cost of path 1 to N. Problem statement − We have given an undirected graph ... Read More

Advertisements