3816. DNA Pattern Recognition
My accepted SQL solution to LeetCode problem 3816, DNA Pattern Recognition, running in 268ms.
- Difficulty: Medium
- SQL
- Runtime 268ms
- Memory 0.0B
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
SQL
Accepted on LeetCode — runtime 268ms, memory 0.0B, accepted 2026-01-02.
SELECT
sample_id,
dna_sequence,
species,
IF(dna_sequence LIKE 'ATG%', 1, 0) AS has_start,
IF(dna_sequence LIKE '%TAA' OR dna_sequence LIKE '%TAG' OR dna_sequence LIKE '%TGA', 1, 0) AS has_stop,
IF(dna_sequence LIKE '%ATAT%', 1, 0) AS has_atat,
IF(dna_sequence LIKE '%GGG%', 1, 0) AS has_ggg
FROM Samples
ORDER BY sample_id