## Dynamic Programming

This yields the following algorithm

 ```1 2 3 4 5 6 7 8 9 ``` `int LPS(char* str, int a, int b) {` `  if (a > b)` `     return 0;` ``` ``` `  if (a == b)` `     return 1;` ``` ``` `   if (str[a] == str[b])` `     return LPS(str, a+1, b-1) + 2 ;` ``` ``` `   return max(LPS(str, a+1, b), LPS(str, a, b-1));` `}`

// Returns the length of the longest palindromic subsequence in seq

`int` `lps(``char` `*seq, ``int` `i, ``int` `j)`
`{`
`   ``// Base Case 1: If there is only 1 character`
`   ``if` `(i == j)`
`     ``return` `1;`
`   ``// Base Case 2: If there are only 2 characters and both are same`
`   ``if` `(seq[i] == seq[j] && i + 1 == j)`
`     ``return` `2;`
`   ``// If the first and last characters match`
`   ``if` `(seq[i] == seq[j])`
`      ``return` `lps (seq, i+1, j-1) + 2;`
`   ``// If the first and last characters do not match`
`   ``return` `max( lps(seq, i, j-1), lps(seq, i+1, j) );`
`}`
 `/* Driver program to test above functions */` `int` `main()` `{` `    ``char` `seq[] = ``"GEEKS FOR GEEKS"``;` `    ``int` `n = ``strlen``(seq);` `    ``printf` `(``"The length of the LPS is %d"``, lps(seq));` `    ``getchar``();` `    ``return` `0;` `}`
Output:
`The length of the LPS is 7`

### Hackerrank > SQL > Basic Select

Select
01-Select All
Given a City table, whose fields are described as +-------------+----------+ | Field       | Type     | +-------------+----------+ | ID          | int(11)  | | Name        | char(35) | | CountryCode | char(3)  | | District    | char(20) | | Population  | int(11)  | +-------------+----------+
write a query that will fetch all columns for every row in the table.

My Solution
SELECT*FROM city;
---------------------------------------------------------------------------------
02-Select by ID
Given a City table, whose fields are described as

### Zoho Puzzle Questions With Answers

Measuring Time Logic Puzzle You are given with two ropes with variable width. However if we start burning both the ropes, they will burn at exactly same time i.e. an hour. The ropes are non-homogeneous in nature. You are asked to measure 45 minutes by using these two ropes.

How can you do it?

Please note that you can’t break the rope in half as it is being clearly stated that the ropes are non-homogeneous in nature.
Answer & Explanation Solution: 45 minutes

Explanation :
All you have to do is burn the first rope from both the ends and the second rope from one end only simultaneously. The first rope will burn in 30 minutes (half of an hour since we burned from both sides) while the other rope would have burnt half. At this moment, light the second rope from the other end as well. Where, the second rope would have taken half an hour more to burn completely, it will take just 15 minutes as we have lit it from the other end too.

Thus you have successfully calculated 30+15 = 45 minutes …