Skip to content
Back to libraryPart 1 · Foundations

1.4Counting and frequency

Before you start

It helps to have read 1.3 Arrays and strings. Overall level: Foundation.

Practice: Counting and frequency

0 of 4 solved

About these problems

Apply, Connect, Reason and Stretch describe difficulty within this topic, not an official contest rating. Open any problem in any order; reading the chapter first is optional.

  1. 1Alphabet tallyYou are given a string s of lowercase English letters. Count how many times each letter from a to z appears in s.ApplyNot started
  2. 2Most common readingA sensor gives a list of n readings a1, a2, ..., an. Find the value that appears most often in the list. If several values appear equally often, print the smallest of them.ConnectNot started
  3. 3Rearrange the labelYou are given two strings s and t of lowercase English letters. Decide whether the letters of s can be rearranged to form exactly t, using every letter of s exactly once. The two strings may have different lengths. Print YES if it is possible, otherwise print NO.ReasonNot started
  4. 4Equal-reading pairsA sensor log is a list of n integers a1, a2, ..., an. Count the pairs of positions i < j with ai = aj.StretchNot started

Read the lesson