Given two strings text1 and text2, return the length of their longest common subsequence. If none exists, return 0.
Input: text1 = "abcde", text2 = "ace"
Output: 3
Explanation: LCS is 'ace'.
Topics: dp
Asked by: Amazon, Google, Meta, Microsoft, Apple, Bloomberg
Time complexity: O(m×n). Space complexity: O(n).