All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g1101_1200.s1143_longest_common_subsequence.Solution.swift Maven / Gradle / Ivy

The newest version!
// #Medium #Top_100_Liked_Questions #String #Dynamic_Programming
// #Algorithm_II_Day_17_Dynamic_Programming #Dynamic_Programming_I_Day_19
// #Udemy_Dynamic_Programming #Big_O_Time_O(n*m)_Space_O(n*m)
// #2024_07_03_Time_12_ms_(98.60%)_Space_16.1_MB_(98.60%)

class Solution {
    func longestCommonSubsequence(_ text1: String, _ text2: String) -> Int {
        let text1 = Array(text1), text2 = Array(text2)
        let n = text1.count 
        let m = text2.count
        var dp = [Int](repeating: 0, count: m + 1)
        for i in 0..




© 2015 - 2025 Weber Informatics LLC | Privacy Policy