Found 26504 Articles for Server Side Programming

Anagram Substring Search using Python

Yaswanth Varma
Updated on 24-Jul-2025 15:54:54

337 Views

An anagram is a rearrangement of the characters of a word or a phrase to generate a new word, using all the original characters exactly once. For example, thing and night are anagrams of each other. An anagram substring search includes two strings (text, pattern); we need to search the given text for any substring that contains the same characters as the pattern, in any order. Scenario Following is an example scenario: Input: str1="cbaebabacd", str2="abc" Output: [0, 6] Explanation: In this case, The substring "cba" at index 0 is an anagram of "abc". The substring "bac" at index 6 is an ... Read More

Adding a new column to existing DataFrame in Pandas in Python

Hafeezul Kareem
Updated on 26-Aug-2023 08:39:59

35K+ Views

In this tutorial, we are going to learn how to add a new column to the existing DataFrame in pandas. We can have different methods to add a new column. Let's all of them.Using ListWe can add a new column using the list. Follow the steps to add a new column.Algorithm1. Create DataFrame using a dictionary. 2. Create a list containing new column data. Make sure that the length of the list matches the length of the data which is already present in the data frame. 3. Add the list to the DataFrame like dictionary element.Let's see one example.Example# importing ... Read More

Anagram checking in Python program using collections.Counter()

Yaswanth Varma
Updated on 14-Jul-2025 15:08:00

287 Views

An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once. For example, thing and night are anagrams of each other. In this article, we are going to learn how to check an anagram in a Python program using collections.Counter() method. This method counts the number of occurrences of each element in a collection (like characters in a string), helping us to compare two words for identical character counts. For example, Scenario Input: str1= "listen", str2= "silent" Output: True Two strings are said ... Read More

Analysing Mobile Data Speeds from TRAI with Pandas in Python

Yaswanth Varma
Updated on 14-Jul-2025 15:23:33

208 Views

The Telecom Regulatory Authority of India (TRAI) publishes the data regarding mobile internet speeds for various telecom operations across India. It is useful for users and telecom companies to evaluate and compare the performance of different service providers. In this article, we are going to use pandas in Python to analyze the TRAI mobile data speed reports. Let's assume we have downloaded the CSV file named demo.csv with the following structure to use in the examples. demo.csv file ... Read More

Find numbers a and b that satisfy the given condition in C++

Arnab Chakraborty
Updated on 01-Nov-2019 10:35:58

550 Views

Consider we have an integer n. Our task is to find two numbers a and b, where these three conditions will be satisfied.a mod b = 0a * b > na / b < nIf no pair is found, print -1.For an example, if the number n = 10, then a and b can be a = 90, b = 10. This satisfies given rules.To solve this problem, we will follow these steps −Let b = n. a can be found using these three conditionsa mod b = 0 when a is multiple of ba / b < n, so ... Read More

Find N digits number which is divisible by D in C++

Arnab Chakraborty
Updated on 01-Nov-2019 10:33:46

173 Views

Suppose we have two numbers N and D. We have to find N digit number, that is divisible by D. If N is 3, and D is 5, then the number can be 500. This can be solved easily. If D is 10 and N is 1, then it will be impossible. We can put D, and suppose the D has m number of digits, then attach N – m number of 0s to make it N digit number and divisible by D.Example#include using namespace std; string nDigitDivByD(int n, int d) {    string ans = "";    if (d ... Read More

Find most significant set bit of a number in C++

Arnab Chakraborty
Updated on 01-Nov-2019 10:28:04

2K+ Views

Here we will see if a number is given, then how to find the value of Most Significant Bit value, that is set. The value is power of 2. So if the number is 10, MSB value will be 8.We have to find the position of MSB, then find the value of the number with a set-bit at kth position.Example#include #include using namespace std; int msbBitValue(int n) {    int k = (int)(log2(n));    return (int)(pow(2, k)); } int main() {    int n = 150;    cout

Find middle of singly linked list Recursively in C++

Arnab Chakraborty
Updated on 01-Nov-2019 10:26:31

511 Views

Consider we have a list of numbers; our task is to find the middle of the linked list using recursion. So if the list elements are [12, 14, 18, 36, 96, 25, 62], then the middle element is 36.To solve this problem, we will count total number of nodes in the list in recursive manner and do half of this. Then rolling back through recursion decrement n by 1 in each call, return element where n is zero.Example#include #include using namespace std; class Node{    public:       int data;       Node *next; }; Node* getNode(int data){ ... Read More

Find maximum element of each row in a matrix in C++

Arnab Chakraborty
Updated on 01-Nov-2019 10:23:30

687 Views

Consider we have a matrix, our task is to find the maximum element of each row of that matrix and print them. This task is simple. For each row, reset the max, and find the max element, and print it. Let us see the code for better understanding.Example#include #define MAX 10 using namespace std; void largestInEachRow(int mat[][MAX], int rows, int cols) {    for (int i = 0; i < rows; i++) {       int max_row_element = mat[i][0];    for (int j = 1; j < cols; j++) {       if (mat[i][j] > max_row_element)          max_row_element = mat[i][j];    }    cout

Find maximum element of each column in a matrix in C++

Arnab Chakraborty
Updated on 01-Nov-2019 10:21:54

563 Views

Consider we have a matrix, our task is to find the maximum element of each column of that matrix and print them. This task is simple. For each column, reset the max, and find the max element, and print it. Let us see the code for better understanding.Example#include #define MAX 10 using namespace std; void largestInEachCol(int mat[][MAX], int rows, int cols) {    for (int i = 0; i < cols; i++) {       int max_col_element = mat[0][i];    for (int j = 1; j < rows; j++) {       if (mat[j][i] > max_col_element)          max_col_element = mat[j][i];    }    cout

Advertisements