Tag: single
Reverse a Singly Linked List in a Single Iteration
Suppose we have a linked list and we want to reverse it in Single iteration and O(n) complexity. Original Linked List, Linked List Reversed Linked List, Advertisements Reversed Linked List Our Node structure is, struct node { Â Â Â int value; Â Â Â node * nextPtr;Â Â Â Â Â Â node(int val) Â Â Â { Â Â Â Â Â Â value = val; …
Python : How to replace single or multiple characters in a string ?
In this article we will discuss how to replace single or multiple characters in a string in Python. Python provides a str.replace() function i.e. Advertisements str.replace(old, new , count) It returns a new string object that is a copy of existing string with replaced content. Also, If count is not provides then it will return …
Python : How to replace single or multiple characters in a string ?Read More
Python: How to unzip a file | Extract Single, multiple or all files from a ZIP archive
In this article we will discuss different ways to unzip or extract single, multiple or all files from zip archive to current or different directory. In Python’s zipfile module, ZipFile class provides a member function to extract all the contents from a ZIP archive, Advertisements ZipFile.extractall(path=None, members=None, pwd=None) It accepts following arguments : path : …
Python: How to unzip a file | Extract Single, multiple or all files from a ZIP archiveRead More
Count occurrences of a single or multiple characters in string and find their index positions
In this article we will discuss different ways to count occurrences of a single character or some selected characters in a string and find their index positions in the string. Count Occurrences of a single character in a String using string.count() In Python the String class contains a method to count to the occurrences of …
Pandas : Change data type of single or multiple columns of Dataframe in Python
In this article we will discuss how to change the data type of a single column or multiple columns of a Dataframe in Python. Change Data Type of a Single Column To change the data type of a single column in dataframe, we are going to use a function series.astype(). Let’s first discuss about this …
Pandas : Change data type of single or multiple columns of Dataframe in PythonRead More
Python Set: Remove single or multiple elements from a set?
In this article we will discuss different ways to remove single or multiple elements from a set in python. Remove a single element from a set Suppose we have a set of numbers in python, Advertisements # Create a set of numbers set_of_num = {1, 2, 11, 6, 7, 4, 5} print(‘Original Set: ‘) print(set_of_num) …
Python Set: Remove single or multiple elements from a set?Read More
How to get multiple counts in single MySQL query
This article will be taking an example table customer_data and will try to get multiple counts from this table within a single query. Topics covered: COUNT(*) GROUP BY COUNT(DISTINCT) BASED ON CONDITION Let us get started by creating the table customer_data and inserting the data into it. CREATE TABLE customer_data ( customer_id INT , customer_name VARCHAR(255), customer_address VARCHAR(255), customer_level …
Javascript: Replace multiple spaces with a single space
A lot of standard requirements are there in javascript related to the processing of strings. One such generic requirement is to replace multiple spaces with a single space in a javascript string. This article will discuss and demonstrate how to remove duplicate spaces using various example illustrations. Table of Contents:- Replace multiple spaces with a …
Javascript: Replace multiple spaces with a single spaceRead More
Create List of single item repeated N times in Python
In this article, we will learn different ways to create a list of single item repeated N times in Python. Table Of Contents Method 1: Using Astrik Method 2: Using List comprehension Method 3: Using itertools Summary Method 1: Using Astrik We can create a list object with one element only, and then multiply that …
Create List of single item repeated N times in PythonRead More
DROP multiple columns in MySQL with single ALTER statement
This article will see how to DROP multiple columns from a MySQL table with a single ALTER statement. Multiple columns can be deleted from the MySQL table using a single ALTER statement by separating the DROP keyword and column name list with a comma. SYNTAX:- ALTER TABLE table_name DROP column1, DROP column2, DROP column3……..; EXAMPLE:- Advertisements Let …
DROP multiple columns in MySQL with single ALTER statementRead More