< Summary

Information
Class: LeetCode.Algorithms.TrionicArray1.TrionicArray1Iterative
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\TrionicArray1\TrionicArray1Iterative.cs
Line coverage
76%
Covered lines: 26
Uncovered lines: 8
Coverable lines: 34
Total lines: 75
Line coverage: 76.4%
Branch coverage
70%
Covered branches: 17
Total branches: 24
Branch coverage: 70.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
IsTrionic(...)70.83%322476.47%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\TrionicArray1\TrionicArray1Iterative.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.TrionicArray1;
 13
 14/// <inheritdoc />
 15public class TrionicArray1Iterative : ITrionicArray1
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="nums"></param>
 22    /// <returns></returns>
 23    public bool IsTrionic(int[] nums)
 224    {
 225        var n = nums.Length;
 26
 227        if (n < 4)
 128        {
 129            return false;
 30        }
 31
 132        var i = 1;
 33
 334        while (i < n && nums[i - 1] < nums[i])
 235        {
 236            i++;
 237        }
 38
 139        if (i < 2)
 040        {
 041            return false;
 42        }
 43
 144        if (i == n)
 045        {
 046            return false;
 47        }
 48
 149        var p = i;
 50
 351        while (p < n && nums[p - 1] > nums[p])
 252        {
 253            p++;
 254        }
 55
 156        if (p == i)
 057        {
 058            return false;
 59        }
 60
 161        if (p == n)
 062        {
 063            return false;
 64        }
 65
 166        var q = p;
 67
 268        while (q < n && nums[q - 1] < nums[q])
 169        {
 170            q++;
 171        }
 72
 173        return q == n && q > p;
 274    }
 75}

Methods/Properties

IsTrionic(System.Int32[])