< Summary

Information
Class: LeetCode.Algorithms.MakeStringSubsequenceUsingCyclicIncrements.MakeStringSubsequenceUsingCyclicIncrementsTwoPointers
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\MakeStringSubsequenceUsingCyclicIncrements\MakeStringSubsequenceUsingCyclicIncrementsTwoPointers.cs
Line coverage
88%
Covered lines: 15
Uncovered lines: 2
Coverable lines: 17
Total lines: 47
Line coverage: 88.2%
Branch coverage
92%
Covered branches: 13
Total branches: 14
Branch coverage: 92.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CanMakeSubsequence(...)92.85%141488.23%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\MakeStringSubsequenceUsingCyclicIncrements\MakeStringSubsequenceUsingCyclicIncrementsTwoPointers.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2025 Eugene Eremeev (also known as Yevhenii Yeriemeieiv).
 3// All Rights Reserved.
 4// --------------------------------------------------------------------------------
 5// This software is the confidential and proprietary information of Eugene Eremeev
 6// (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not
 7// disclose such Confidential Information and shall use it only in accordance with
 8// the terms of the license agreement you entered into with Eugene Eremeev (also
 9// known as Yevhenii Yeriemeieiv).
 10// --------------------------------------------------------------------------------
 11
 12namespace LeetCode.Algorithms.MakeStringSubsequenceUsingCyclicIncrements;
 13
 14/// <inheritdoc />
 15public class MakeStringSubsequenceUsingCyclicIncrementsTwoPointers : IMakeStringSubsequenceUsingCyclicIncrements
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n + m)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="str1"></param>
 22    /// <param name="str2"></param>
 23    /// <returns></returns>
 24    public bool CanMakeSubsequence(string str1, string str2)
 325    {
 326        if (str2.Length > str1.Length)
 027        {
 028            return false;
 29        }
 30
 331        var str1Index = 0;
 332        var str2Index = 0;
 33
 1034        while (str1Index < str1.Length && str2Index < str2.Length)
 735        {
 736            if (str1[str1Index] == str2[str2Index] || (str1[str1Index] == 'z' && str2[str2Index] == 'a') ||
 737                str1[str1Index] + 1 == str2[str2Index])
 438            {
 439                str2Index++;
 440            }
 41
 742            str1Index++;
 743        }
 44
 345        return str2Index == str2.Length;
 346    }
 47}