AYUSH MISHRA

AYUSH MISHRA

112 Articles Published

Articles by AYUSH MISHRA

Page 7 of 12

Sorting strings with decimal points in C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 21-Mar-2025 2K+ Views

A string containing decimal points is sorted to solve complex programming problems. This question was asked in the Accenture coding assessment in 2025. In C++, there are different ways to sort such strings efficiently. In this article, we are going to discuss various approaches to sorting strings that contain decimal points using C++. How to Sort Strings with Decimal Points? In this problem, we are given an array of strings, where each string represents a decimal number. The goal is to sort these strings in increasing numerical order while ensuring the correct handling of decimal values. Example 1 ...

Read More

Sorting an array of binary values - C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 21-Mar-2025 468 Views

Sorting an array of binary values (0s and 1s) is a common problem in programming. In C++, there are multiple ways to efficiently sort an array containing only 0s and 1s. In this article, we are going to learn various approaches to sorting an array of binary values using C++. How to Sort an Array of Binary Values? In this problem, we are given an array that consists of only 0s and 1s. The task is to sort the array in ascending order, which means all 0s should come before all 1s. Example 1 ...

Read More

Python Program for finding nth term of H.P.

AYUSH MISHRA
AYUSH MISHRA
Updated on 20-Mar-2025 1K+ Views

A Harmonic Progression ( H.P.) is a sequence of numbers where the reciprocals of the terms form an Arithmetic Progression (A.P.). In simple terms, if we take the reciprocal of each term in an H.P., the resulting sequence will be in A.P. In this problem, we are given the first term, common difference, and value of n of which we have to find the nth term of given H.P. Find the nth term of H.P. To find the nth term of Harmonic Progression, we first convert the H.P. into an A.P. by finding reciprocals of the terms. The formula ...

Read More

Find the number that appears once, and the other numbers twice in Python

AYUSH MISHRA
AYUSH MISHRA
Updated on 20-Mar-2025 2K+ Views

Finding a unique number in a list that appears only once while all other numbers appear twice is a common and important problem in programming. We can find the unique number in a list using multiple ways. The most efficient approach is using an XOR operator, as this method solves this problem in constant time and space complexity. In this article, we are going to discuss various approaches to finding the number that appears once while all others appear twice. Finding the Unique Number When we are given a list of numbers where every number appears twice except one ...

Read More

First and last position of an element in a sorted array in C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 20-Mar-2025 4K+ Views

The first and last position of any element in a sorted array is a common operation in the world of programming. In C++, there are multiple ways to find the first and last position of an element in a sorted array. In this article, we are going to discuss various approaches for finding the first and last occurrence of an element in a sorted array using C++. How to Find the First and Last Position of an Element? In this problem, we are given a sorted array and a target element. We need to find the first and last ...

Read More

Sort an array which contain 1 to n values

AYUSH MISHRA
AYUSH MISHRA
Updated on 19-Mar-2025 6K+ Views

Sorting an array containing values from 1 to n means arranging the integers in their natural ascending order. This type of sorting problem is commonly encountered in competitive programming (for solving complex problems), where the array is guaranteed to have integers ranging from 1 to n. In this article, we will explore various approaches to solving this problem. In this problem, we are given an array containing values ranging from 1 to n in random order. Our goal is to sort the array in ascending order. Example 1 Input: int array[] = {3, 1, 2, ...

Read More

C++ Program to Rotate Array Right by One Position

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 18-Mar-2025 6K+ Views

Rotating an array means shifting its elements in a specific direction while maintaining their relative order. In this article, we will rotate an array right by one position using C++. For example, if the array is {4, 8, 15, 16, 23}, rotating it right once will result in {23, 4, 8, 15, 16}. We are given an array and need to shift all elements one step to the right, with the last element moving to the first position. Example 1 Input:array = {10, 20, 30, 40, 50} Output:array = {50, 10, ...

Read More

C++ Program to Count the Sum of Numbers in a String

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 18-Mar-2025 85 Views

In this problem, we are given a string containing alphanumeric characters, and the task is to extract all the numbers from the string and compute their sum. The numbers may appear anywhere within the string, and we need to identify them and add them together. In this article, we are going to explore different approaches to solving this problem in C++.Example 1Input: str = "anshu123ayush45anshu"Output: Sum = 174Explanation:The numbers extracted from the string are 123, 45, and 6. Their sum is 123 + 45 + 6 = 174.Example 2Input: str = "1abc2def34ghi56jkl"Output: Sum = 93Explanation:The numbers extracted from the string ...

Read More

Check if given four points form a square using C++

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2025 5K+ Views

A square is a four-sided polygon with all sides equal and all angles equal to 90 degrees. In computational geometry, determining whether four given points form a square is a common problem. In this article, we will discuss multiple approaches to check whether four given points in a 2D plane form a square using C++. When can a four-sided polygon be called a Square? If we are given four points, we have to determine whether it is a square or not. To determine if four points (A, B, C, D) form a square, the given conditions below must be satisfied: ...

Read More

C++ program to calculate area of circle

C++
AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2025 4K+ Views

The area of a circle is a fundamental mathematical concept that can be easily calculated using a simple formula. In C++, there are multiple ways to find the area of a circle. In this article, we are going to discuss various approaches to calculating the area of a circle in C++. How to Find the Area of a Circle? The formula for finding the area of a circle with a given radius r is: Area = π × r × r Example 1 Input: r = 5 Output: 78.54 Explanation: ...

Read More
Showing 61–70 of 112 articles
« Prev 1 5 6 7 8 9 12 Next »
Advertisements