| name | array-techniques |
| description | Master essential array techniques including two pointers, sliding window, and prefix sums for efficient problem solving with O(n) patterns. |
| sasmp_version | 1.3.0 |
| bonded_agent | 01-arrays-lists |
| bond_type | PRIMARY_BOND |
| atomic_responsibility | array_pattern_execution |
| version | 2.0.0 |
| parameter_validation | {"strict":true,"rules":[{"name":"array_input","type":"list","required":true,"constraints":{"min_length":0,"max_length":100000}},{"name":"target","type":"integer","required":false},{"name":"window_size","type":"integer","required":false,"constraints":{"min_value":1}}]} |
| retry_logic | {"max_attempts":3,"backoff_ms":[100,200,400],"retryable_errors":["timeout","memory_exceeded"]} |
| logging_hooks | {"on_start":true,"on_complete":true,"on_error":true,"log_format":"[ARR-SKILL] {timestamp} | {operation} | {status}"} |
| complexity_annotations | {"two_pointers":{"time":"O(n)","space":"O(1)"},"sliding_window":{"time":"O(n)","space":"O(1)"},"prefix_sum":{"time":"O(n) build, O(1) query","space":"O(n)"}} |
Array Techniques Skill
Atomic Responsibility: Execute array manipulation patterns with optimal complexity.
Two Pointers Pattern
Same Direction (Fast/Slow)
from typing import List
def remove_element(nums: List[int], val: int) -> int:
"""
Remove all occurrences of val in-place.
Time: O(n), Space: O(1)
Args:
nums: Input array (modified in-place)
val: Value to remove
Returns:
New length of array
Raises:
ValueError: If nums is None
"""
if nums is None:
raise ValueError("Input array cannot be None")
write_ptr = 0
for read_ptr in range(len(nums)):
if nums[read_ptr] != val:
nums[write_ptr] = nums[read_ptr]
write_ptr += 1
return write_ptr
Opposite Direction (Converging)
def two_sum_sorted(arr: List[int], target: int) -> List[int]:
"""
Find two indices in sorted array that sum to target.
Time: O(n), Space: O(1)
Args:
arr: Sorted input array
target: Target sum
Returns:
List of two indices, or empty list if not found
"""
if not arr or len(arr) < 2:
return []
left, right = , (arr) -
left < right:
total = arr[left] + arr[right]
total == target:
[left, right]
total < target:
left +=
:
right -=
[]