< Summary

Information
Class: LeetCode.Algorithms.CheckIfTwoStringArraysAreEquivalent.CheckIfTwoStringArraysAreEquivalentTwoPointers
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CheckIfTwoStringArraysAreEquivalent\CheckIfTwoStringArraysAreEquivalentTwoPointers.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 58
Line coverage: 100%
Branch coverage
91%
Covered branches: 11
Total branches: 12
Branch coverage: 91.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ArrayStringsAreEqual(...)91.66%1212100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CheckIfTwoStringArraysAreEquivalent\CheckIfTwoStringArraysAreEquivalentTwoPointers.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.CheckIfTwoStringArraysAreEquivalent;
 13
 14/// <inheritdoc />
 15public class CheckIfTwoStringArraysAreEquivalentTwoPointers : ICheckIfTwoStringArraysAreEquivalent
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n + m)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="word1"></param>
 22    /// <param name="word2"></param>
 23    /// <returns></returns>
 24    public bool ArrayStringsAreEqual(string[] word1, string[] word2)
 725    {
 726        var wordIndex1 = 0;
 727        var wordIndex2 = 0;
 728        var charIndex1 = 0;
 729        var charIndex2 = 0;
 30
 4531        while (wordIndex1 < word1.Length && wordIndex2 < word2.Length)
 4132        {
 4133            if (word1[wordIndex1][charIndex1] != word2[wordIndex2][charIndex2])
 334            {
 335                return false;
 36            }
 37
 3838            charIndex1++;
 3839            charIndex2++;
 40
 3841            if (charIndex1 == word1[wordIndex1].Length)
 1242            {
 1243                wordIndex1++;
 1244                charIndex1 = 0;
 1245            }
 46
 3847            if (charIndex2 != word2[wordIndex2].Length)
 2848            {
 2849                continue;
 50            }
 51
 1052            wordIndex2++;
 1053            charIndex2 = 0;
 1054        }
 55
 456        return wordIndex1 == word1.Length && wordIndex2 == word2.Length;
 757    }
 58}