# Determine if two sentences are similar | 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/2280/determine-similar-sentences
Source observed: 2026-11-05T00:28:06.970Z
Last checked: 2026-11-05T00:28:06.97+00:00
Indexed: 2026-11-07T02:09:49.285+00:00

---

# Determine if two sentences are similar

**Difficulty:** Medium  
**Question type:** Data Structures & Algorithms; Coding; Technical  
**Roles:** Software Engineer  
**Companies:** [Amazon](https://www.aced.io/questions?company=amazon), [Google](https://www.aced.io/questions?company=google)  
**Reported last asked:** 2 years ago  

## Problem

Determine whether two sentences are similar. The sentences are represented as arrays of words.

Two sentences are similar when:

1. They have the same length.
2. Every pair of words at corresponding positions is similar.

The provided list of similar word pairs defines word similarity. Similarity is directional as listed for the problem’s pairs unless the pair contains the same words in the relevant order. A word is always similar to itself.

For example, with similar pairs:

```text
[("great", "good"), ("acting", "drama"), ("skills", "talent")]
```

these sentences are similar:

```text
"You have great acting skills"
"You have good drama talent"
```

## Examples

### Example 1

```text
sentence1 = ["Let's", "code", "in", "Python"]
sentence2 = ["Let's", "program", "in", "Python"]
similarPairs = [
    ("code", "program"),
]
output: true
```

### Example 2

```text
sentence1 = ["I", "love", "to", "play", "football"]
sentence2 = ["I", "love", "playing", "soccer"]
similarPairs = [("play", "playing"), ("football", "soccer")]
output: false
```

The output is false because the sentences have different lengths.

### Example 3

```text
sentence1 = ["Do", "you", "like", "coffee"]
sentence2 = ["Do", "you", "love", "coffee"]
similarPairs = [
    ("like", "enjoy"),
    ("coffee", "tea"),
]
output: false
```

`"like"` is not similar to `"love"` based on the provided pairs.

### Example 4

```text
sentence1 = ["I", "really", "love", "leetcode", "and", "apples"]
sentence2 = ["I", "so", "like", "codesignal", "and", "oranges"]
similarPairs = [
    ("very", "so"),
    ("love", "adore"),
    ("really", "very"),
    ("leetcode", "codesignal"),
    ("apples", "oranges"),
    ("like", "adore"),
]
output: true
```

## Page controls and availability

We provide tabs for **Question**, **Solution**, **Mock Interview**, and **Community**. The question page includes controls to save the question, report that it was asked, and open more actions. Detailed company statistics require an upgrade, and no community answers have been contributed yet.

The coding workspace includes **Editor**, **Share**, **Output**, **Test Results**, and **Console** views. You can [sign up to run code](https://www.aced.io/signup?src=lesson).

## Interview experiences

We have one shared interview experience associated with this question:

- [Amazon · Software Engineer · Intern](https://www.aced.io/experiences/amazon-software-engineer-intern-interview-9beb3b) — listed as 2 years ago. The interviewer was described as professional and approachable, with a well-structured, collaborative process that provided an opportunity to demonstrate technical and problem-solving skills. The contributor suggested allowing slightly more time for alternative approaches and edge-case testing.

## Related questions

- [Determine if a number is a power of two.](https://www.aced.io/questions/4647/power-of-two)
- [Determine if two words are sorted in lexicographic order.](https://www.aced.io/questions/3431/check-lexicographic-order-two-words)

## Related courses

### [Software Engineering Interview Prep](https://www.aced.io/courses/software-engineering)

![Software Engineering Interview Prep](https://images.ctfassets.net/x78yjrjc11pq/4VkuYewBHUFIVUS5oJDW5h/02e833439b1289f25f38f13f81cbdca3/adobe_stock_optimized.jpeg?w=800&h=800&fm=webp&q=75)

Prepare for software engineering interviews at Google, Amazon, Microsoft, Meta, Apple, and other companies with mock interviews, frameworks, senior-candidate advice, and practice covering data structures, algorithms, system design, people management, and behavioral interviews.

### [System Design Interviews](https://www.aced.io/courses/system-design-interviews)

![System Design Interviews](https://images.ctfassets.net/x78yjrjc11pq/78x7miFZFjBCrM5GqftrMJ/2f6d26e632c4e7265c49f6a180227edb/system_design_track_compressed_26ac98a46e__281_29_5be2280f31.jpeg?w=800&h=800&fm=webp&q=75)

Learn to answer current system design questions across product, infrastructure, and AI domains through in-depth video examples, written breakdowns, reference patterns, and mock interviews with senior engineers and managers.

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F2280%2Fdetermine-similar-sentences&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%2F2280%2Fdetermine-similar-sentences). Opening a form does not execute a tool.