

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Minimum number of letters needed to make a total of n in C++.
<h2>Problem statement</h2><p>Given an integer n and let a = 1, b = 2, c= 3, ….., z = 26. The task is to find the minimum number of letters needed to make a total of n</p><pre class="result notranslate">If n = 23 then output is 1 If n = 72 then output is 3(26 + 26 + 20)</pre><h2>Algorithm</h2><pre class="result notranslate">1. If n is divisible by 26 then answer is (n/26) 2. If n is not divisible by 26 then answer is (n/26) + 1</pre><h2>Example</h2><!--<p><a href="" target="_blank" rel="nofollow" class="demo"><i class="fa-external-link"></i> Live Demo</a></p>--><pre class="prettyprint notranslate">#include <iostream> using namespace std; int minRequiredSets(int n){ if (n % 26 == 0) { return (n / 26); } else { return (n / 26) + 1; } } int main(){ int n = 72; cout << "Minimum required sets: " << minRequiredSets(n) << endl; return 0; }</pre><h2>Output</h2><p>When you compile and execute the above program. It generates the following output −</p><pre class="result notranslate">Minimum required sets: 3</pre>
- Related Questions & Answers
- C++ program to count minimum number of operations needed to make number n to 1
- Minimum number of Appends needed to make a string palindrome in C++
- Program to check minimum number of characters needed to make string palindrome in Python
- Find minimum number of Log value needed to calculate Log upto N in C++
- C++ program to count minimum number of binary digit numbers needed to represent n
- C++ program to find minimum number of punches are needed to make way to reach target
- C++ program to find minimum how many operations needed to make number 0
- Program to find minimum number of rocketships needed for rescue in Python
- Minimum number of given moves required to make N divisible by 25 using C++.
- Minimum number of deletions to make a string palindrome in C++.
- Minimum number of coins that make a given value
- Program to find number of coins needed to make the changes in Python
- C++ program to find minimum number of operations needed to make all cells at r row c columns black
- Count total number of digits from 1 to N in C++
- Total number of non-decreasing numbers with n digits
Advertisements