Stokastik

Machine Learning, AI and Programming

Tag: K-Similar Strings

Leetcode : K-Similar Strings

Problem Statement Solution: The brute force approach is to evaluate all possible swaps. Given the string is of length N, the number of possible pairs is U=0.5*N*(N-1). But observe that not just the swaps but the sequence of swaps also matters. The number of possible sequence of swaps is U!. Thus the run-time complexity is O(U!). For moderately sized value of N such as 20 as given by the problem […]

Continue Reading →