Find Longest Repetitive Sequence in a String in Python

Yaswanth Varma
Updated on 10-Jun-2025 19:20:08

3K+ Views

Strings are the essential data types used in many real-world problems that involve analysing and manipulating text data. In this article, we are going to learn about finding the longest repetitive sequence in a string. The Repetitive sequence refers to a substring that appears more than once in the given string. For performing this task, Python provides built-in features.  Using Suffix Array and LCP A suffix array is used to store all the suffixes of the given string in lexicographic order. In this approach, we will consider the input string and create a list of all ... Read More

Efficiently Repeat a String to a Certain Length in Python

Yaswanth Varma
Updated on 10-Jun-2025 19:19:10

1K+ Views

In Programming, it is useful to repeat or pad a string up to a certain length. Whether generating the formatted output, filling templates, or being able to repeat the string to a specific length can save time. In this article, we are exploring an efficient way to repeat a string to a certain length. Python provides various ways, such as using multiplication, string slicing, and built-in methods like ljust(), rjust(),  and zfill(). Using String Multiplication The first approach is by using the * operator. Here, we are going to repeat the string to a specific length using the ... Read More

Substring Slicing Index Out of Range in Python

Yaswanth Varma
Updated on 10-Jun-2025 19:14:50

4K+ Views

In many programming languages, trying to access the element that is out of range of a string or list results in the IndexError. But Python behaves differently when it comes to substring slicing. Instead of generating the error, Python handles the out-of-range in slicing operations by adjusting the indices to fit the valid limits. This makes the Python slicing safe and appropriate. Let's dive into the article to understand how slicing with out-of-range indices works in Python with examples. Python slice() Function The Python slice() function is used to return the slice object that can be used ... Read More

Decimal Fixed Point and Floating Point Arithmetic in Python

Nikitasha Shrivastava
Updated on 10-Jun-2025 19:07:53

2K+ Views

This article will explain how decimal fixed-point and floating-point arithmetic work in Python, which is useful for performing accurate calculations in various applications. Numbers in Python can be stored in two ways: floating-point and decimal fixed-point. Floating-point numbers are fast but can sometimes be incorrect because of how computers store them. On the other hand, Decimal fixed-point numbers are more accurate and useful when working with precise calculations.  By the end of this article, you will understand how both types of numbers work, when to use them, and how to write programs using them. Floating-Point Arithmetic The following example will ... Read More

Creating Iterators for Efficient Looping in Python

Nikitasha Shrivastava
Updated on 10-Jun-2025 19:01:35

272 Views

In this article, we will talk about creating iterators for efficient looping in Python functions. An iterator is something that helps you go through all the items one by one, like going through pages of a book one page at a time. In Python, we can use lists, tuples, dictionaries, and sets as iterators. So we will explore Python functions that generate iterators for efficient looping. Creating Iterators with Functions Python provides different ways to create iterators using functions. So let us see some examples of creating iterators for efficient looping in Python functions - Using Generator Functions Using ... Read More

Use the PI Constant in C++

Aman Kumar
Updated on 10-Jun-2025 18:53:08

20K+ Views

The Pi is a special mathematical value, approximately 3.14159, that is often used in calculations related to circles and geometry. In C++, we need to understand how to access and use this constant in our programs. In this article, we will show how to use the PI constant in a C++ program. The PI constant is available in the cmath header file. We will explain how to use PI to calculate values like the area or circumference of a circle. How to Use Pi in C++ There are multiple ways to use the Pi constant in C++. ... Read More

Parsing Command Line Parameters in C++

Aman Kumar
Updated on 10-Jun-2025 18:52:52

336 Views

In this article, we will learn how to pass command line parameters in C++. The command line argument is a parameter that is passed to a program when it is invoked by the command line or terminal. Parsing Command Line Parameters in C++ In C++, we can pass the command line argument using the argc and argv[] parameters that are passed to the main function. Where argc refers to the number of arguments passed, and argv[] is a pointer array that points to each argument passed to the program. We can use loops to iterate and parse the command line ... Read More

Import External Libraries in JShell in Java 9

Alshifa Hasnain
Updated on 10-Jun-2025 18:42:54

2K+ Views

In this article, we will learn to import external libraries in JShell in Java 9. JShell is an interactive tool to learn the Java language and prototype Java code. This tool works on the principle of REPL (Read-Evaluate-Print-Loop). Default Imports in JShell By default, JShell automatically imports a few useful Java packages when the JShell session is started. We can type the command /imports to get a list of all these imports. jshell> /imports | import java.io.* | import java.math.* | import java.net.* | import java.nio.file.* | import java.util.* | import java.util.concurrent.* | import java.util.function.* | import java.util.prefs.* | import ... Read More

New Methods Added to the Arrays Class in Java 9

Alshifa Hasnain
Updated on 10-Jun-2025 18:42:26

253 Views

In this article, we will learn about the new methods that have been added to the Arrays class in Java 9. First, we will learn about arrays, and then the new methods added to the equals(), compare(), and mismatch() methods with examples. Arrays Java provides a data structure called the Array, and they are used to store multiple values of the same datatype in a single variable. The Arrays class can contain various methods for manipulating arrays and also contains static factory methods that allow arrays to view as a list. Creating an instance of an Array with a variable ... Read More

Useful Commands in JShell for Java 9

Alshifa Hasnain
Updated on 10-Jun-2025 18:42:06

517 Views

In this article, we will learn about useful commands in JShell. Java 9 has introduced a new interactive tool called JShell. This tool can be used to execute, test user-friendly and easy way of Java classes, interfaces, enums, objects, statements and etc.  Different Useful Commands in JShell Below are some of the important commands in JShell: /open /var /types /methods /list /help /open To execute a script after JShell has started, we will use ... Read More

Advertisements