Articles on Trending Technologies

Technical articles with clear explanations and examples

Tutorix - AI Tutor

Find N Geometric Means between A and B using C++.

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 285 Views

Suppose we have three integers A, B and N. We have to find N geometric means between A and B. If A = 2, B = 32, and N = 3, then the output will be 4, 8, 16The task is simple we have to insert N number of elements in the geometric Progression where A and B are the first and last term of that sequence. Suppose G1, G2, …. Gn are n geometric means. So the sequence will be A, G1, G2, …. Gn, B. So B is the (N + 2)th term of the sequence. So we ...

Read More

Escaping Characters in Perl

Mohd Mohtashim
Mohd Mohtashim
Updated on 11-Mar-2026 701 Views

Perl uses the backslash (\) character to escape any type of character that might interfere with our code. Let's take one example where we want to print double quote and $ sign −Example#!/usr/bin/perl $result = "This is "number""; print "$result"; print "\$result";OutputThis will produce the following result −This is "number" $result

Read More

Find number of magical pairs of string of length L in C++.

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 254 Views

Suppose we have two strings str1 and str2, we have to find a number of magical pairs of length L. Two strings will be magical if for every index I, the str1[i] < str2[i]. We have to count a number of pairs since the number is very large, then return the answer using modulo 109. The strings will hold only lowercase letters.The approach is simple. As we can see, if the length is L = 1, and index i = 1 is holding ‘a’, in str1 then index i = 1 of str2 will hold from ‘b’ to ‘z’ so ...

Read More

Find closest smaller value for every element in array in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 270 Views

Here we will see how to find the closest value for every element in an array. If an element x has the next element that is larger than it, and also present in the array, then that will be the greater value of that element. If the element is not present, then return -1. Suppose the array elements are [10, 5, 11, 6, 20, 12], then the greater elements are [11, 6, 12, 10, -1, 20]. As 20 has not greater value in the array, then print -1.To solve this, we will use the settings in C++ STL. The set ...

Read More

Find one extra character in a string using C++.

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 517 Views

Suppose we have two strings S and T, the length of S is n, and the length of T is n + 1. The T will hold all characters that are present in S, but it will hold one extra character. Our task is to find the extra character using some efficient approach.To solve this problem, we will take one empty hash table, and insert all characters of the second string, then remove each character from the first string, the remaining character is an extra character.Example#include #include using namespace std; char getExtraCharacter(string S, string T) {    unordered_map char_map;   ...

Read More

What are Perl String Literals?

Mohd Mohtashim
Mohd Mohtashim
Updated on 11-Mar-2026 1K+ Views

Strings are sequences of characters. They are usually alphanumeric values delimited by either single (') or double (") quotes. They work much like UNIX shell quotes where you can use single-quoted strings and double-quoted strings.Double-quoted string literals allow variable interpolation, and single-quoted strings are not. There are certain characters when they are proceeded by a backslash, have special meaning and they are used to represent like newline () or tab (\t).You can embed newlines or any of the following Escape sequences directly in your double-quoted strings −Escape sequenceMeaning\Backslash'Single quote"Double quote\aAlert or bell\bBackspace\fForm feedNewline\rCarriage return\tHorizontal tab\vVertical tab\0nnCreates Octal formatted numbers\xnnCreates Hexideciamal ...

Read More

Find original array from encrypted array (An array of sums of other elements) using C++.

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 685 Views

Let us consider we have an array of integers, that array is encrypted array, Suppose the array is A = [10, 14, 12, 13, 11], the original array is B = [5, 1, 3, 2, 4], we can see that each element at index I of A follows this rule: A[i] = sum of all elements at position j in B[j], where I ≠ j. Our task is to find an original array from the encrypted one.The task is based on arithmetic observation. Suppose the array is of size 4, original array B has four elements B = [a, b, ...

Read More

Perl Scalar Variables

Mohd Mohtashim
Mohd Mohtashim
Updated on 11-Mar-2026 311 Views

A scalar is a single unit of data. That data might be an integer number, floating-point, a character, a string, a paragraph, or an entire web page. Simply saying it could be anything, but only a single thing.Here is a simple example of using scalar variables −Example#!/usr/bin/perl $age = 25;                   # An integer assignment $name = "John Paul";         # A string $salary = 1445.50;           # A floating point print "Age = $age"; print "Name = $name"; print "Salary = $salary";OutputThis will produce the following result −Age = 25 Name = John Paul Salary = 1445.5

Read More

Find the number of binary strings of length N with at least 3 consecutive 1s in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 476 Views

Suppose, we have an integer N, We have to find the number of all possible distinct binary strings of the length N, which have at least three consecutive 1s. So if n = 4, then the numbers will be 0111, 1110, 1111, so output will be 3.To solve this, we can use the Dynamic programming approach. So DP(i, x) indicates number of strings of length i with x consecutive 1s in position i + 1 to i + x. Then the recurrence relation will be like −DP(i, x) = DP(i – 1, 0) + DP(i – 1, x + 1).The ...

Read More

Perl Array Variables

Mohd Mohtashim
Mohd Mohtashim
Updated on 11-Mar-2026 344 Views

An array is a variable that stores an ordered list of scalar values. Array variables are preceded by an "at" (@) sign. To refer to a single element of an array, you will use the dollar sign ($) with the variable name followed by the index of the element in square brackets.Here is a simple example of using array variables −Example#!/usr/bin/perl @ages = (25, 30, 40); @names = ("John Paul", "Lisa", "Kumar"); print "\$ages[0] = $ages[0]"; print "\$ages[1] = $ages[1]"; print "\$ages[2] = $ages[2]"; print "\$names[0] = $names[0]"; print "\$names[1] = $names[1]"; print "\$names[2] = $names[2]";Here we used escape sign ...

Read More
Showing 28541–28550 of 61,297 articles
Advertisements