< Summary

Information
Class: LeetCode.Algorithms.DesignHashMap.DesignHashMapIntArray
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\DesignHashMap\DesignHashMapIntArray.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 50
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
Put(...)100%11100%
Get(...)100%11100%
Remove(...)100%11100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\DesignHashMap\DesignHashMapIntArray.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.DesignHashMap;
 13
 14/// <inheritdoc />
 15public class DesignHashMapIntArray : IDesignHashMap
 16{
 117    private readonly int[] _items = new int[1_000_001];
 18
 19    /// <summary>
 20    ///     Time complexity - O(1)
 21    ///     Space complexity - O(1)
 22    /// </summary>
 23    /// <param name="key"></param>
 24    /// <param name="value"></param>
 25    public void Put(int key, int value)
 326    {
 327        _items[key] = value + 1;
 328    }
 29
 30    /// <summary>
 31    ///     Time complexity - O(1)
 32    ///     Space complexity - O(1)
 33    /// </summary>
 34    /// <param name="key"></param>
 35    /// <returns></returns>
 36    public int Get(int key)
 437    {
 438        return _items[key] - 1;
 439    }
 40
 41    /// <summary>
 42    ///     Time complexity - O(1)
 43    ///     Space complexity - O(1)
 44    /// </summary>
 45    /// <param name="key"></param>
 46    public void Remove(int key)
 147    {
 148        _items[key] = 0;
 149    }
 50}