< Summary

Information
Class: LeetCode.Algorithms.CountVowelStringsInRanges.CountVowelStringsInRangesPrefixSum
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CountVowelStringsInRanges\CountVowelStringsInRangesPrefixSum.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 51
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
VowelStrings(...)100%88100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CountVowelStringsInRanges\CountVowelStringsInRangesPrefixSum.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.CountVowelStringsInRanges;
 13
 14/// <inheritdoc />
 15public class CountVowelStringsInRangesPrefixSum : ICountVowelStringsInRanges
 16{
 217    private readonly HashSet<char> _vowelsHashSet =
 218    [
 219        'a',
 220        'e',
 221        'i',
 222        'o',
 223        'u'
 224    ];
 25
 26    public int[] VowelStrings(string[] words, int[][] queries)
 227    {
 228        var prefixSum = new int[words.Length + 1];
 29
 2030        for (var i = 0; i < words.Length; i++)
 831        {
 832            if (_vowelsHashSet.Contains(words[i][0]) && _vowelsHashSet.Contains(words[i][^1]))
 733            {
 734                prefixSum[i + 1] = prefixSum[i] + 1;
 735            }
 36            else
 137            {
 138                prefixSum[i + 1] = prefixSum[i];
 139            }
 840        }
 41
 242        var result = new int[queries.Length];
 43
 1644        for (var i = 0; i < queries.Length; i++)
 645        {
 646            result[i] = prefixSum[queries[i][1] + 1] - prefixSum[queries[i][0]];
 647        }
 48
 249        return result;
 250    }
 51}