In Python, an index is an element's location within an ordered list. Where n is the length of the list, and the first entry has a zero index, and the last element has an n-1 index. In this tutorial, we will look at how to find out the index of an element in a list in Python. There are different methods to retrieve the index of an element. Using index() method Three arguments can be passed to the list index() method in Python - element: element that has to be found. start ... Read More
We can build regular expressions that recognize repeated character groups using a few special characters. The following metacharacters can be used to search for a character or set of repeated characters. The question mark was the first repeating operator or quantifier developed. It effectively makes it optional by instructing the engine to try matching the previous token 0 or 1 times. Matching Simple HTML Tags Using Regular Expressions The engine is instructed to try matching the previous token zero or more times by the asterisk or star. The plus instructs the engine to make one or more attempts to match ... Read More
In this article, you will learn how to match any single lowercase vowel (a, e, i, o, u) using Python regular expressions (regex). We will understand how to use Python's re module to apply a pattern that finds these vowels in a string. Ways to Match Lowercase There are two ways to match any one lowercase vowel in Python using a Regular Expression. One is using the if loop, and the other is using a regular expression. Using the General Method ... Read More
In Java, both constants and final variables are used to define variables that cannot be changed after initialization. But they have some differences. In this article, we will learn how they are different. Final Variable A final variable in Java means you cannot reassign it after it has been initialized. Whether it is a local variable, instance variable, or static variable, once it's assigned, the value cannot be changed. If you try to do so, a compile-time error will be generated. public class FinalExample { public static void main(String args[]) { ... Read More
In this problem, we are given an array, and we have to replace each element with its rank. The rank of an element is the position of the element when element of the array is arranged in sorted order. In this article, we are going to learn about various approaches to replacing elements with their rank in an array using JavaScript. Below are the examples to understand the problem clearly - Example 1: Input: arr = [40, 10, 20, 30] Output: [4, 1, 2, 3] Explanation: The sorted, unique array is: [10, 20, ... Read More
A single character can be matched in Python using a regular expression. A regular expression is a sequence of characters that helps you find a string or a set of strings using a search pattern. Regular expressions are also known as RegEx. Python provides the re module that is used to work with regular expressions - Using findall() function We use findall() searches for the strings matching the specified pattern in the given string and return all the matches in the form of a list of strings or tuples. Example 1 In the following example, we begin by importing the regular ... Read More
A circular linked list is a type of linked list where the last node and first node are the same, forming a loop. There are many real-life applications of splitting a circular linked list into two halves for easier processing, load balancing, or efficient data manipulation. In this article, we are going to learn different approaches to split a circular linked list into two halves in C++. What is the Splitting of a Circular Linked List? Splitting of a Circular linked list is dividing the given linked list into two separate linked lists: If ... Read More
Finding the Kth largest element in a 2D matrix where each row and column is sorted is a common problem in computer science. This problem has many real-life applications, such as a ranking system, where we need to find the Kth highest score in a sorted dataset. In this article, we are going to discuss how we can find the Kth largest element in a 2D matrix e where each row and column is in sorted order in the C++ language. What is the Kth Largest Element? The Kth largest element refers to an element that is placed at ... Read More
In this article, we will learn the different approaches to replace a part of a string with another string using a C/C++ program. The problem statement of this program is explained below: The input of this problem will be three strings. The task is to replace all the occurrence of the second string with the third string inside the first string. For example: // Input strings "C++ Course is free on Tutorialspoint" "C++" "Python" // Output String "Python Course is free on Tutorialspoint" Replace a Substring With Another String Here is the list of all ... Read More
A Python dictionary is an unordered, mutable collection of key-value pairs. Keys must be unique and immutable, while the other values can be of any other type. Dictionaries are useful for fast data storage and organization using meaningful keys. Optimizing Python Dictionary To optimize Python dictionaries, use suitable key types like strings or integers and pre-size them using methods such as dict.fromkeys() or collections.defaultdict() function. This enhances access speed, reduces memory usage, and specific overall performance. Optimizing dictionary access in Python can significantly improve performance in large programs. Here are several ways to do that with explanations and examples - ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP