You are not logged in. Please login at www.codechef.com to post your questions!

×

REPUB - Editorial

PROBLEM LINK:

Practice
Contest

Author: Ranjan Kumar Singh
Tester: Ved Prakash
Editorialist: Sudipto Roy

DIFFICULTY:

CAKEWALK

PRE-REQUISITES:

Arrays

PROBLEM:

To find the alphabet with the heighest frequency.

EXPLANATION:

For the given string, first check if the string has capital alphabet or small alphabet. Increment the frequency array according to what alphabet is found.

Pseudo Code:

for i=1 to 26:
    count[i]=0    //counting frequency
for i=1 to l(length of string):
    if(str[i] is lower alphabet) count[str[i]-'a']++;
    else if(str[i] is capital alphabet) count[str[i]-'A']++;   //selecting heighest frequency
max_freq=0
for i=1 to 26:
    if(count[i]>=max_freq) max=count[i],index=i

Complexity: O(N).

SOLUTIONS:

Setter's solution
Tester's solution

asked 05 Feb '15, 00:10

sudipto_roy's gravatar image

3★sudipto_roy
1037
accept rate: 15%

retagged 05 Feb '15, 12:41

mediocoder's gravatar image

3★mediocoder
1.1k313

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×15,852
×1,688
×15

question asked: 05 Feb '15, 00:10

question was seen: 407 times

last updated: 05 Feb '15, 12:41