Found 34472 Articles for Programming

Python Program for Converting Roman Numerals to Decimal Lying Between 1 to 3999

Prabhdeep Singh
Updated on 11-Jul-2023 21:34:23

295 Views

Roman numerals are known as the characters used in an arrangement of number notation based on the pre-Roman Roman system. All major symbols are covered in the section below. In this problem, we are given a string of Roman numerals and our task is to convert Roman numerals to decimals in the range of 1 to 3999 Here are some examples and explanations to help you better understand the problem. Input str = “MXCIX” Output 1099 Explanation M is the Roman representation of 1000, XC is the Roman representation of 90, IX is the Roman representation of 9. Input str ... Read More

Largest Roman Numeral Possible by Rearranging Characters of a Given String

Prabhdeep Singh
Updated on 11-Jul-2023 16:07:53

89 Views

The characters represent Roman numbers: 'I', 'V', 'X', 'L', 'C', 'D', and 'M'. We will be given a string that may contain another character also (all the characters will be uppercase English alphabets) and we have to find the largest Roman numerical number possible by altering the position of the characters of the given string, also if it is not possible to get one, then we will return invalid as the answer. Input 1 string str = “VICML” Output MCLVI Explanation In the given string we have M have the greater value followed by the C, and then all ... Read More

Karatsuba Algorithm for Fast Multiplication of Large Decimal Numbers Represented as Strings

Prabhdeep Singh
Updated on 11-Jul-2023 21:20:07

262 Views

We are not able to store the large decimal numbers in normal data types such as the int or even in long long, so we store them in the string. When we multiply two integers represented in the form of a string it takes a lot of time more specifically N*M where N is the size of the given string. In this article, we will implement Karatsuba Algorithm for the fast Multiplication of large decimal numbers represented as strings. Input string num1 = "34984" string num2 = "937488" Output 32797080192 Explanation We will see the algorithm for the ... Read More

Python3 Program to Minimize Characters to be Changed to Make the Left and Right Rotation of a String the Same

Prabhdeep Singh
Updated on 11-Jul-2023 15:05:05

51 Views

Rotation means we have to shift each character either in a forward direction or backward direction. Forward direction means right rotation (Or anticlockwise) and backward direction means left rotation (Or clockwise). In this problem, we have given a string of size n. Our task is to find the minimum number of the character to be changed to check whether it is possible to the make left rotation and right rotation of a string the same. Let's see examples with explanations below to understand the problem in a better way. Input 1 str = "wxyz" Output 1 2 Explanation The ... Read More

PHP Program to Check if all rows of a matrix are circular rotations of each other

Prabhdeep Singh
Updated on 11-Jul-2023 14:50:21

64 Views

A rectangular array called a matrix is made up of rows and columns. And circular rotations entail rotating the array's elements so that after one rotation, the last member is in the first position and the other elements are shifted to the right. We are given an N*N matrix in this problem, and our objective is to determine whether all of the rows are circular rotations of one another. If they are, print "YES, " otherwise print "NO." In order to better understand the issue, let's look at some cases with explanations below. Input 1 mat = [ [ 7, ... Read More

Java Program to Check if all Rows of a Matrix are Circular Rotations of Each Other

Prabhdeep Singh
Updated on 11-Jul-2023 14:14:22

116 Views

Matrix consists of rows and columns to form a rectangular array. And circular rotations mean rotating the array's elements so that one rotation places the last element in the first position and the rest of the elements to the right. In this problem, we have given a matrix of n * n, and our task is to check if all rows of a matrix are circular rotations of each other then print “YES” otherwise print “NO”. Let's see examples with explanations below to understand the problem in a better way. Input 1 mat = [ [ 1, 5, 6], ... Read More

Microsoft Visual Studio Alternatives

Shirjeel Yunus
Updated on 11-Jul-2023 12:44:52

130 Views

What is Microsoft Visual Studio? Microsoft Visual Studio is a developer tool which can be used to develop standalone as well as web−based applications. It has an integrated development environment(IDE) which can be used to write code, debug and edit it. Other tools available on this platform are compilers, source control, code completion tools, extensions, and a lot more. You can build and test applications through .NET and C++ and you can also edit ASP.NET pages. Price Plans of Microsoft Visual Studio There are four price plans and the details are available in the table below: ... Read More

Python Program to Splitting String into a Number of Sub-strings

Rohan Singh
Updated on 11-Jul-2023 14:38:21

109 Views

In Python, we can split a string into substrings using the split() method. The split() method is one of the built-in Python string methods that splits a string into a list of substrings based on a specified delimiter. In this article, we will learn how to split strings into substrings with the help of Examples. Splitting String into Substring Method 1: Using the split() method The split() method is a built-in method of strings in Python that splits a string into a list of sub-strings based on a specified delimiter. The delimiter can be any character or string that ... Read More

Python Program to Replace a Character at a Specific Index

Rohan Singh
Updated on 11-Jul-2023 14:31:19

19K+ Views

In Python, we can easily replace a character at a specific index by converting the string into a list of characters using the list() method. Then, we modify the character at the desired index and convert the list back to the string using the join() method. We can also replace a character at a specific index using the slicing and replace method. In this article, we will see examples of replacing a character at a specific index in Python using list and join method, the slicing method and replace method. Method 1: Using list() and join() method Syntax The list() ... Read More

Python Program to Print the first letter of each word using regex

Rohan Singh
Updated on 11-Jul-2023 14:28:13

2K+ Views

Regex library in Python is used for pattern matching and manipulation of text data. We can print the first letter of each word using regex by identifying a new word after spaces using its pattern-matching functionality. In this article, we will implement a program to print the first letter of each word using regex. Regular Expressions Regular expression or regex is a tool for pattern matching in text. They are a sequence of characters that define a search pattern. They are widely used in programming, particularly in text processing, and are supported by most programming languages, including Python. Printing ... Read More

Advertisements