Created
April 30, 2018 08:20
-
-
Save rsmahmud/55e6d7c8b07beb3d362d8ad9b50c9b5a to your computer and use it in GitHub Desktop.
HackerRank Problem 1: find how many times "code out" can be printed from given string. can't use same character twice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n,st = int(input()),input() | |
letters = ["c","d","e"," ","u","t"] | |
print(min(min(list(map(lambda x:st.count(x),letters))),st.count("o")//2)) | |
""" | |
Andrew loves programming and simply immerses himself in all programming problems he could lay his hands on. He sat in a contest recently and came across an interesting problem. The problem was that he was given a string of random letters and his job was to find the maximum number of times he could spell the word "code out" using all the letters. | |
Note: Andrew could rearrange the letters to form the word "code out" however, every letter can be used once only. | |
Input Format: | |
The first line of input contains a number n which is the total number of characters present in the string. This is followed by a string consisting of exactly n characters. The string contains all lowercase characters as well as spaces. | |
Constraints: | |
1<=n<=100000 | |
Output Format | |
An integer which is the maximum number of times Andrew can spell the word "code out" from the letters provided to him. | |
Sample Explanation: | |
In this sample input, we can form "code out" only 1 times, hence the answer is 1. | |
Sample Input: | |
8 | |
code out | |
Sample Output: | |
1 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment