- 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

# Program to count how many times we can find "pizza" with given string characters in Python

Suppose we have a lowercase string s, we have to find how many "pizza" strings we can make using the characters present in s. We can use the characters in s in any order, but each character can be used once.

So, if the input is like "ihzapezlzzilaop", then the output will be 2.

To solve this, we will follow these steps −

- p_freq := Frequency of 'p' in s
- i_freq := Frequency of 'i' in s
- z_freq := Frequency of 'z' in s
- a_freq := Frequency of 'a' in s
- return minimum of (p_freq, i_freq, z_freq/2 and a_freq)

Let us see the following implementation to get better understanding −

## Example

class Solution: def solve(self, s): p_freq = s.count('p') i_freq = s.count('i') z_freq = s.count('z') a_freq = s.count('a') return min(p_freq, i_freq, z_freq // 2, a_freq) ob = Solution() print(ob.solve("ihzapezlzzilaop"))

## Input

"ihzapezlzzilaop"

## Output

2

- Related Questions & Answers
- Program to find how many ways we can climb stairs (maximum steps at most k times) in Python
- Python Program to Determine How Many Times a Given Letter Occurs in a String Recursively
- Program to find how many ways we can climb stairs in Python
- How many times can we sum number digits in JavaScript
- Program to count number of unique palindromes we can make using string characters in Python
- Program to find maximum how many water bottles we can drink in Python
- C++ program to count in how many ways we can paint blocks with two conditions
- Program to find how many times a character appears in a string in PHP
- Program to count how many blocks are covered k times by walking in Python
- Program to find how many total amount of rain we can catch in Python
- Program to count how many ways we can divide the tree into two trees in Python
- Program to count how many ways we can cut the matrix into k pieces in python
- Python program to count upper and lower case characters in a given string.
- Count how many times the given digital clock shows identical digits in C++
- Program to check whether we can make k palindromes from given string characters or not in Python?

Advertisements