< Summary

Information
Class: LeetCode.Algorithms.TrimTrailingVowels.TrimTrailingVowelsIterative
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\TrimTrailingVowels\TrimTrailingVowelsIterative.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 36
Line coverage: 100%
Branch coverage
100%
Covered branches: 18
Total branches: 18
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TrimTrailingVowels(...)100%66100%
IsVowel(...)100%1212100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\TrimTrailingVowels\TrimTrailingVowelsIterative.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2026 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.TrimTrailingVowels;
 13
 14/// <summary>
 15///     Time complexity - O(n)
 16///     Space complexity - O(1)
 17/// </summary>
 18public sealed class TrimTrailingVowelsIterative : ITrimTrailingVowels
 19{
 20    public string TrimTrailingVowels(string s)
 321    {
 322        var length = s.Length;
 23
 1024        while (length > 0 && IsVowel(s[length - 1]))
 725        {
 726            length--;
 727        }
 28
 329        return length == s.Length ? s : s[..length];
 330    }
 31
 32    private static bool IsVowel(char c)
 933    {
 934        return c is 'a' or 'e' or 'i' or 'o' or 'u';
 935    }
 36}