Found 7401 Articles for C++

Modify String by Replacing Characters by Alphabets whose distance from that Character is Equal to its Frequency

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 12:36:00

78 Views

Modifying a string by replacing characters with alphabets whose distance from that character is equal to its frequency is an intriguing problem that involves manipulating strings in a unique way. The task is to take a given string as input and replace each character in the string with an alphabet that is at a distance equal to the frequency of that character in the string. For instance, if the character 'a' appears three times in the string, it would be replaced by an alphabet that is three positions away from 'a' in the English alphabet. This problem presents an interesting ... Read More

Longest Common Subsequence (LCS) by Repeatedly Swapping Characters of a String with Characters of Another String

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 12:08:51

62 Views

Longest Common Subsequence (LCS) is a classic problem in computer science that involves finding the longest subsequence that is present in two given strings. In this tutorial, we will explore a unique approach to solving this problem, which involves repeatedly swapping characters between the two strings until we find the LCS. This approach involves a bit of creativity and is not commonly used, but it can be useful in certain situations. We will be using the C++ programming language to implement this solution, and we will provide a step-by-step guide on how to do so. So, let's dive in ... Read More

Check if any Pair of Consecutive 1s can be Separated by at most M 0s by Circular Rotation of a Binary String

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 12:13:11

31 Views

Checking if any pair of consecutive 1s can be separated by at most M 0s by circular rotation of a Binary String is a common problem in computer programming and binary manipulation. The task is to determine whether a given binary string can be rotated in a circular manner such that any pair of consecutive 1s in the string can be separated by at most M 0s. This problem arises in various applications, such as image processing, data compression, and information retrieval. In this tutorial, we will delve into the intricacies of this problem statement and provide a solution ... Read More

Check if a Binary String contains A pairs of 0s and B independent 0s or not

Aishwarya Mani Tripathi
Updated on 08-Sep-2023 12:28:21

62 Views

Checking if a Binary String contains A pairs of 0s and B independent 0s or not is a common problem encountered in computer science, particularly in the field of algorithms and data structures. The problem statement is quite simple and plays a significant role in various fields, such as cryptography, network security, and machine learning. In this tutorial, we will discuss a solution to this problem using C++. We will first provide an overview of the approach starting with defining the problem statement with some examples and, then we will dive into the implementation details. So let’s get started! ... Read More

Time Required to Meet in Equilateral Triangle

Vanshika Sood
Updated on 08-Sep-2023 11:42:35

58 Views

An equilateral triangle is a triangle with all of its sides equal in length. As the three sides are equal, the three angles opposing the equal sides are also equal in magnitude. As a result, it is also known as an equiangular triangle, with each angle measuring 60 degrees. The centroid of an equilateral triangle is the point where its three medians intersect. In an equilateral triangle, all three sides are of equal length and all three angles are of equal measure, so each median will intersect at the same point, which is the centroid. Problem Statement Given length ... Read More

Program to calculate Volume and Surface area of Hemisphere

Vanshika Sood
Updated on 08-Sep-2023 11:34:47

166 Views

A sphere is a three-dimensional geometric shape that is perfectly round like a ball, while a hemisphere is one half of a sphere. In essence, a sphere would split into two hemispheres if it were sliced in half. Hemispheres are identified by their curving surface, which radiates out from the sphere's core. The Greek terms "hemi" (half) and "sphaira" (sphere) are where the name "hemisphere" comes from. Hemispheres are used to describe and simulate a variety of events in a number of disciplines, including geography, astronomy, mathematics, and physics. Volume of a Hemisphere The volume of a hemisphere is equal ... Read More

Numbers whose Factorials end with n Zeros

Vanshika Sood
Updated on 08-Sep-2023 11:46:46

112 Views

A factorial of a number is the product of all positive integers up to the given number. For example, the factorial of 5 is denoted as 5! and is equal to the product of all positive integers up to 5: 5! = 5 x 4 x 3 x 2 x 1 = 120 The number of zeros at the end of the decimal representation of a number's factorial is referred to as the "trailing zeros" in a factorial. The factorial of 5, for instance, is 120, which has one trailing zero, while the factorial of 10, on the other hand, ... Read More

Leibniz Harmonic Triangle

Vanshika Sood
Updated on 08-Sep-2023 11:19:04

90 Views

The Leibniz harmonic triangle, also known as Leibniz's series or the Leibniz formula, is a triangular arrangement of numbers discovered by German mathematician and philosopher Gottfried Wilhelm Leibniz in the late 17th century. The Leibniz harmonic triangle is a triangular arrangement of fractions. We start at the top with the number and the outermost terms are reciprocal of the natural numbers depicting that particular row number. In general, a term in the leibniz harmonic triangle can be determined by the following equation, where r is the row number and c is the column number with the condition that c

First Occurrence of a Digit in a Given Fraction

Vanshika Sood
Updated on 08-Sep-2023 11:11:02

57 Views

The decimal expansion of a fraction is the decimal representation of the fraction's value. In the following article we discuss two approaches to find the first occurrence of c in a/b. Problem Statement Given three integers a, b, c, locate the first instance of c in the fraction a/b after the decimal point. Print-1 if it does not exist. Sample Examples Input a = 5, b = 6, c = 3 Output 2 Explanation $$\mathrm{\frac{a}{b}=\frac{5}{6}=0.83333}$$ So c=3 occurs at the 2nd place after the decimal point. Hence the output is 2. Input a = -10, b = ... Read More

Minimize the Absolute Difference of Sum of Two Subsets

Vanshika Sood
Updated on 08-Sep-2023 11:06:08

191 Views

To Minimize the Absolute Difference of Sum of Two Subsets, we partition a vector into two subsets i.e. we divide the elements of the vector into two smaller vectors such that each element of the original vector belongs to one of the two smaller vectors, and the two smaller vectors are disjoint. For example, if we have a vector v = {1, 2, 3, 4, 5}, then one possible partitioning of v into two subsets is S1 = {1, 3, 4} and S2 = {2, 5}, where each element of v belongs to either S1 or S2, and the ... Read More

Advertisements