# Decrypt Message — Aced

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/3054/decrypt-message
Source observed: 2026-11-05T00:28:03.065Z
Last checked: 2026-11-05T00:28:03.065+00:00
Indexed: 2026-11-07T01:42:41.225+00:00

---

# Decrypt Message

**Difficulty:** Medium  
**Categories:** [Data Structures & Algorithms](https://www.aced.io/questions?type=algorithms), [Coding](https://www.aced.io/questions?type=coding)  
**Interview metadata:** Reported last asked: 3 years ago

We provide this coding question for practicing efficient string algorithms. It asks you to implement `decrypt(word)` for a word encrypted using cumulative ASCII values.

## Problem

An infamous gang of cybercriminals named “The Gray Cyber Mob” has been targeted by the FBI. The gang encrypts messages, and each word is encrypted separately. Every message consists only of lowercase Latin letters.

### Encryption procedure

1. Convert every letter to its [ASCII value](http://asciitable.com/).
2. For the first letter, add `1` to its ASCII value. For every subsequent letter, add the encrypted ASCII value of the previous letter to that letter’s original ASCII value.
3. For each resulting value, subtract `26` repeatedly until it is within the ASCII range for lowercase letters `a-z`, then convert the values back to letters.

For example, the word `crime` begins with the following encryption steps:

```text
Step 1: 99
Step 2: 100
Step 3: 100
Result: d
```

## Task

Write a function named `decrypt(word)` that accepts a string containing lowercase Latin letters only and returns the decrypted word.

Because the function may be used on messages containing many words, make it as efficient as possible in both time and space. Include:

- An explanation of why the function is correct.
- An analysis of its asymptotic runtime complexity.
- An analysis of its asymptotic space complexity.

Most programming languages provide built-in methods for converting letters to ASCII values and back. The question links to [ASCII value information](http://asciitable.com/).

## Examples

```text
input:  word = "dnotq"
output: "crime"

input:  word = "flgxswdliefy"
output: "encyclopedia"
```

## Practice interface

The page includes expandable sections for **Hint 1**, **Hint 2**, **Challenge 1**, **Challenge 2**, and **Challenge 3**, plus an editor with **Editor**, **Share**, **Output**, **Test Results**, and **Console** panels. The solution tab is separate from the question tab. No community answers have been contributed yet; the community area is marked with 14 interactions.

You can [sign up to run code](https://www.aced.io/signup?src=lesson). Detailed company statistics for the question are available through [Upgrade](https://www.aced.io/upgrade?src=questions).

## Related Aced resources

We provide interview preparation through courses and practice resources, including:

- [Software Engineering](https://www.aced.io/courses/software-engineering?src=nav) — Learn essential strategies for coding problems and more.
- [System Design](https://www.aced.io/courses/system-design-interviews?src=nav) — Define architectures, interfaces, and databases in a time crunch.
- [Data Structures & Algorithms questions](https://www.aced.io/questions?type=algorithms)
- [Coding questions](https://www.aced.io/questions?type=coding)
- [All questions](https://www.aced.io/questions)

We are Aced, formerly Exponent.

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3054%2Fdecrypt-message&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3054%2Fdecrypt-message). Opening a form does not execute a tool.