Find Maximum Fruit Count to Make Compote in C++

Farhan Muhamed
Updated on 31-Jul-2025 17:02:43

568 Views

In this article, we will explain maximum fruit count to make compote problem and implement a C++ program to solve it. The problem involves finding the maximum number of fruits that can be used to make a compote, given certain constraints. Let's break down the problem statement below. Maximum Fruit Count to Make Compote You are given a list of fruits, say a apples, b bananas, and c cherries, where a, b, and c are the counts of each type of fruit. Your task is to make a compote using these fruits such that the apples, bananas and cherries ... Read More

Compare Float and Double in C++

sudhir sharma
Updated on 31-Jul-2025 16:10:44

747 Views

In C++, floating-point numbers are used to represent decimal values. The most commonly used floating-point types are float and double. These data types differ in their size, precision, and use cases. Understanding how to use and compare them correctly is important for accurate computations. Understanding Float and Double Precision The float is a 32-bit single-precision floating-point type that can store approximately 7 decimal digits, while double is a 64-bit double-precision type that offers about 15 to 16 digits of precision. Due to these differences, double is generally preferred for higher accuracy in scientific and financial calculations. Example: Printing ... Read More

All Unique Triplets That Sum Up to a Given Value in C++

Manisha Chand
Updated on 31-Jul-2025 15:40:28

416 Views

Unique Triplets that Sum up to a Given Value In this article, we will discuss different approaches to find all the unique triplets that sum up to the given value. Before that, first understand the given problem. We have been given an integer array with N elements, along with a target value. Our task is to find unique or distinct triplets (i.e., three numbers) from an array, whose sum is the same as the target value. Let's take a scenario to understand the problem in a better way: Scenario 1 Input: arr ={1, 2, 3, 4, 5, 6, 7} ... Read More

Almost Perfect Number in C++

Manisha Chand
Updated on 31-Jul-2025 15:23:45

219 Views

Almost Perfect Number in C++ Almost Perfect Number is a positive integer n for which the sum of all its positive proper divisors (excluding the number itself ) is equal to n-1. (i.e., one less than the number n). It is also known as the least deficient number or slightly defective number. A positive proper divisor is a divisor of a number, excluding the number itself. For example, for n = 6; 1, 2, 3 are positive proper divisors but 6 itself is not. In Mathematics, we say A number n is almost perfect if: σ(n)-n = n-1 by ... Read More

Aliquot Sum in C++

Manisha Chand
Updated on 31-Jul-2025 14:59:55

268 Views

Aliquot sum in C++ Aliquot sum of a positive integer n is the sum of all proper divisors of n. A positive proper divisor is a divisor of a number, excluding the number itself. For example, for n = 6; 1, 2, 3 are positive proper divisors but 6 itself is not. Scenario 1 Input: n = 20 Output: 22 Explanation: Proper divisors of 20 are: 1, 2, 4, 5, 10 Sum of proper divisors are: 1 + 2 + 4 + 5 + 10 = 22 So, aliquot sum of 20 is : 22 Scenario 2 Input: 15 ... Read More

Delete Node in a Linked List in Python

sudhir sharma
Updated on 31-Jul-2025 12:49:23

4K+ Views

A linked list is a linear data structure where each element is a separate object, commonly referred to as a node. Each node contains two fields: the data and a pointer to the next node in the list. In this article, we'll learn how to delete a node from a singly linked list using Python. Suppose we have a linked list with a few elements. Our task is to delete a specific node, given only access to that node - not the head of the list. For example: Input: 1 → 3 → 5 → 7 → ... Read More

C++ Code to Find Minimum Arithmetic Mean Deviation

Ravi Ranjan
Updated on 31-Jul-2025 12:03:45

253 Views

The arithmetic mean deviation or mean absolute deviation is the summation of the absolute differences of each element and the mean of the dataset, then dividing it by the total number of data elements. To calculate the minimum arithmetic mean deviation, we used the median of the dataset in place of the mean. The formula to calculate the minimum arithmetic mean deviation is given as: $$ \text{MMD} = \frac{1}{n} \sum_{i=1}^{n} |x_i - M| = \frac{|x_1 - M| + |x_2 - M| + \cdots + |x_n - M|}{n} $$ Here are some example scenarios to calculate the ... Read More

Add One Row to Tree in C++

Nishu Kumari
Updated on 30-Jul-2025 19:18:18

229 Views

We are given the root of a binary tree and two integers, val and depth. The root of the binary tree is at depth 1. Our task is to add a new row of nodes with value val at the given depth. If the depth is 1, we have to create a new root node with value val and make the original tree its left child. If the depth is greater than 1, we go to all nodes at depth depth - 1, add new left and right child nodes with value val, and connect the original left and right ... Read More

Check If Any Anagram of a String Is Palindrome in Python

Yaswanth Varma
Updated on 30-Jul-2025 18:50:48

452 Views

Check if any Anagram of a String is Palindrome An anagram is a rearrangement of the characters of a word or a phrase to generate a new word, using all the original characters exactly once. For example, thing and night are anagrams of each other. While palindrome is a word or phrase that reads the same forward and backward, like madam, racecar. In this article, we are going to check if any anagram of a string is a palindrome or not, i.e., we are not just checking whether the given string itself is a palindrome, but also whether it can ... Read More

Check If an Array Represents Inorder of Binary Search Tree in Python

Yaswanth Varma
Updated on 30-Jul-2025 18:44:15

563 Views

The Binary Search Tree (BST) is a widely used data structure that maintains the elements in a sorted hierarchical order. Each node in the BST follows the specific property: The values in the left subtree are always less than the values of the current node. The values in the right subtree are always greater than the node. In this article, we are going to learn about checking if an array represents the inorder of a BST or not in Python. Checking for inorder of the BST Inorder traversal is the ... Read More

Advertisements