We use cookies (including Google cookies) to personalize ads and analyze traffic. By continuing to use our site, you accept our Privacy Policy.

DNA Pattern Recognition

Number:

Difficulty: Medium

Paid? No

Companies: None


Problem Description

AI-Generated Solutions

Python

JavaScript

C++

In each programming language, the SQL query is provided to solve the DNA Pattern Recognition LeetCode question. The query checks for specific patterns in the DNA sequences and assigns a value of 1 if the pattern is present, or 0 if it is not. The results are then ordered by sample_id in ascending order.

# SQL query to solve the problem
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 REGEXP 'GGG|GGGG', 1, 0) AS has_ggg
FROM Samples
ORDER BY sample_id;
← Back to All Questions