Phonebook Lookup

Easy
3 views 24 Jan 2026
Read n entries of name and phone. Then one query name is provided. Output the phone if present else output NOT FOUND....

Unique Words Count

Easy
3 views 24 Jan 2026
A line sentence is provided. Words are separated by spaces. Count how many unique words are there and output the count....

Last Value for Key

Easy
4 views 24 Jan 2026
Read n pairs key value. If a key appears many times, keep the last value. After all pairs, output value for query key, or NA if key never appeared....

Sum of Dictionary Values

Easy
3 views 24 Jan 2026
Read n pairs key and integer value. Add all values and output total sum. Keys may repeat, still add every time....

Key Exists

Easy
2 views 24 Jan 2026
Read n keys (one per line). Then query key is provided. Output YES if query exists else NO....

Digit Frequency

Easy
3 views 24 Jan 2026
A string of digits is provided. Count frequency of each digit 0 to 9 and output 10 integers in one line....

Count By First Letter

Easy
2 views 24 Jan 2026
Read n words. Count how many words start with each first letter. Output results sorted by letter as: letter count each on new line....

Merge Two Score Lists

Easy
3 views 24 Jan 2026
Read n pairs in list A and m pairs in list B (key and score). Make final score for each key as sum of scores from both lists (missing is 0). Output keys sorted with their final score....

Key With Maximum Value

Easy
3 views 24 Jan 2026
Read n pairs key value (integer). Compute the key with maximum value. If tie, pick lexicographically smallest key. Output the key....

Word Frequency Table

Medium
2 views 24 Jan 2026
Read n words (one per line). Output each distinct word with its count, sorted by word....

Top K Frequent Words

Medium
3 views 24 Jan 2026
Read n words and integer k. Output top k words by frequency (desc), tie by word (asc)....

Ledger with GET

Medium
2 views 24 Jan 2026
You have a dictionary of balances. Commands: ADD name x, SUB name x, GET name. Missing name starts at 0. For GET, output current balance....

First Non-Repeating Word

Medium
2 views 24 Jan 2026
Read n words in order. Output the first word that appears exactly once. If none, output NONE....

Count Pairs with Same Value

Medium
3 views 24 Jan 2026
Read n keys with integer values. Count how many unordered pairs of keys have same value. Output the number....

Anagram Group Count

Medium
4 views 24 Jan 2026
Read n words. Two words are anagrams if their letters can be rearranged. Count how many distinct anagram groups are there and output it....

First Index Map

Medium
2 views 24 Jan 2026
Read n integers. Store the first index (1-based) for each distinct value. Then q queries follow, each query is a value. Output its first index or -1....

Counter with Delete

Medium
3 views 24 Jan 2026
You have q commands: INC key, DEC key. Start counts at 0. If after DEC the count becomes 0, remove the key from dictionary. At end output number of keys left....

Intersection of Keys

Medium
2 views 24 Jan 2026
Read two dictionaries A and B as lists of keys. Output how many keys are present in both....

Parse Key:Value Pairs

Medium
2 views 24 Jan 2026
One line has pairs like key:value separated by spaces. Build dictionary and output how many pairs were parsed and sum of all integer values....

Prefix Count Queries

Medium
3 views 24 Jan 2026
Read n words. For each word, count all its prefixes. Then q prefixes are provided. For each prefix output how many words start with it....

Evaluate Simple Expression

Medium
2 views 24 Jan 2026
Read n assignments like name value (integer). Then one expression is provided as: name1 op name2 where op is + or -. Output result using stored values. Missing names are treated as 0....

Reverse Map Count

Medium
2 views 24 Jan 2026
Read n pairs key value. Build reverse mapping: for each value, how many keys map to it. Output values sorted with their counts....

Rename Key Safely

Medium
2 views 24 Jan 2026
Read q operations: SET k v, RENAME old new. RENAME works only if old exists and new does not exist. At end output number of keys and then keys sorted....

Count Subarrays Sum K

Hard
3 views 24 Jan 2026
Read n integers and target K. Count number of subarrays with sum exactly K. Output the count....

Longest Subarray with At Most K Distinct

Hard
3 views 24 Jan 2026
Read n integers and K. Compute length of the longest contiguous subarray that has at most K distinct numbers....

Smallest Window Contains Pattern

Hard
3 views 24 Jan 2026
Read string s and pattern p (both no spaces). Compute the length of smallest substring of s that contains all characters of p with at least same counts. If not possible output 0....

LRU Cache Simulator

Hard
2 views 24 Jan 2026
You have cache capacity cap. Commands: GET key, PUT key value. For GET output value if present else -1. LRU eviction is used when capacity exceeded....

Nested Dictionary Path

Hard
3 views 24 Jan 2026
You will receive q commands on a nested dictionary: SET path value, GET path. Path is dot separated like a.b.c. For GET output value if exists else NOT FOUND....

Inventory Commands

Hard
3 views 24 Jan 2026
You have an inventory counts dictionary. Commands: ADD item x, REMOVE item x, COUNT item. Missing item starts at 0. REMOVE cannot make count below 0 (stop at 0). For COUNT output current count....

First Unique Number Stream

Hard
2 views 24 Jan 2026
You will receive q operations: ADD x or FIRST. ADD adds number x to stream. FIRST should output the first number that has appeared exactly once so far, or -1 if none....

Keys by Value Range

Hard
3 views 24 Jan 2026
Read n pairs key value. Then two integers L and R. Output how many keys have value in range [L,R]....

Frequency of Frequencies

Hard
3 views 24 Jan 2026
Read n words. Build frequency of each word. Then q queries of integer f. For each query, output how many distinct words have frequency exactly f....

Swap Values of Two Keys

Easy
3 views 24 Jan 2026
Read n key-value pairs (string keys and string values). Then two keys k1 and k2 are provided. If both keys exist, swap their values. Finally output value of k1 and value of k2 (use NA if a key does no...

Max Value Per Key

Medium
2 views 24 Jan 2026
Read n pairs key and integer value. If a key comes many times, keep only the maximum value for that key. After processing, output each key with its max value, sorted by key....

Count Subarrays XOR K

Hard
4 views 24 Jan 2026
Read n integers and target K. Count number of subarrays with bitwise XOR exactly K. Output the count....