| name | hashing-techniques |
| description | Hash-based data structures and techniques including frequency counting, duplicate detection, and LRU cache implementation. |
| sasmp_version | 1.3.0 |
| bonded_agent | 06-hash-tables |
| bond_type | PRIMARY_BOND |
| atomic_responsibility | hash_based_operations |
| version | 2.0.0 |
| parameter_validation | {"strict":true,"rules":[{"name":"input_data","type":"any","required":true},{"name":"capacity","type":"integer","required":false}]} |
| retry_logic | {"max_attempts":3,"backoff_ms":[100,200,400],"retryable_errors":["memory_exceeded","key_error"]} |
| logging_hooks | {"on_start":true,"on_complete":true,"on_error":true,"log_format":"[HSH-SKILL] {timestamp} | {operation} | {status}"} |
| complexity_annotations | {"frequency_count":{"time":"O(n)","space":"O(k) unique elements"},"lru_cache":{"time":"O(1) all operations","space":"O(capacity)"},"group_anagrams":{"time":"O(n * k log k)","space":"O(n * k)"}} |
Hashing Techniques Skill
Atomic Responsibility: Execute hash-based lookups and data organization.
Frequency Counting Pattern
from typing import List
from collections import Counter
import heapq
def top_k_frequent(nums: List[int], k: int) -> List[int]:
"""
Find k most frequent elements.
Time: O(n log k), Space: O(n)
"""
count = Counter(nums)
return heapq.nlargest(k, count.keys(), key=count.get)
def top_k_frequent_bucket(nums: List[int], k: int) -> List[int]:
"""
Bucket sort approach for O(n) time.
Time: O(n), Space: O(n)
"""
count = Counter(nums)
buckets = [[] for _ in range(len(nums) + 1)]
for num, freq in count.items():
buckets[freq].append(num)
result = []
for i in range(len(buckets) - 1, -1, -1):
for num in buckets[i]:
result.append(num)
if len(result) == k:
return result
return result