GenomicRangeQuery::solution()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 24
rs 8.5125
cc 5
eloc 16
nc 5
nop 3
1
<?php
2
3
namespace Lesson03;
4
5
class GenomicRangeQuery
6
{
7
    public function solution($S, $P, $Q)
8
    {
9
        $queries = count($P);
10
        $output = [];
11
        for ($i = 0; $i < $queries; $i++) {
12
            $temp = substr($S, $P[$i], $Q[$i] - $P[$i] + 1);
13
14
            if (strpos($temp, 'A') !== false) {
15
                $output[] = 1;
16
                continue;
17
            }
18
            if (strpos($temp, 'C') !== false) {
19
                $output[] = 2;
20
                continue;
21
            }
22
            if (strpos($temp, 'G') !== false) {
23
                $output[] = 3;
24
                continue;
25
            }
26
            $output[] = 4;
27
        }
28
29
        return $output;
30
    }
31
}
32