MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / lpsRec

Function lpsRec

dynamic/longestpalindromicsubsequence.go:8–19  ·  view source on GitHub ↗
(word string, i, j int)

Source from the content-addressed store, hash-verified

6package dynamic
7
8func lpsRec(word string, i, j int) int {
9 if i == j {
10 return 1
11 }
12 if i > j {
13 return 0
14 }
15 if word[i] == word[j] {
16 return 2 + lpsRec(word, i+1, j-1)
17 }
18 return Max(lpsRec(word, i, j-1), lpsRec(word, i+1, j))
19}
20
21// LpsRec function
22func LpsRec(word string) int {

Callers 1

LpsRecFunction · 0.85

Calls 1

MaxFunction · 0.85

Tested by

no test coverage detected