#

data-structures

Data structures and algorithms in C++

ProgrammingHow to Add New Keys to Python Dictionary

Learn how to add new keys to a Python dictionary using assignment, update(), setdefault(), and merge operators. No dict.add() method—use these efficient idioms for key-value pairs with examples and pitfalls.

1 answer 4 views
ProgrammingEfficient Sock Pairing Algorithm: O(n log n) Guide

Discover the optimal sock pairing algorithm using in-place sorting like heapsort for O(n log n) time under log-space constraints. Compare with hashing, radix methods, and practical tips for 30 pairs. Relates to element distinctness.

1 answer 4 views
ProgrammingCheck if Key Exists in std::map C++: find & contains

Learn how to check if a key exists in std::map using find, contains (C++20), count, and fix equal_range errors. Avoid operator[] inserts with code examples and best practices for C++ map lookups.

1 answer 1 view
ProgrammingPython Subscriptable Objects: Built-in Types & Indexing Guide

Learn what subscriptable means in Python, which built-in types support indexing operations, and how to check if objects support [] syntax with __getitem__.

1 answer 1 view
ProgrammingHow to Access Ith Column of NumPy Multidimensional Array

Learn how to efficiently access the ith column in a NumPy array using slicing like test[:, i]. Get the first column [1, 3, 5] from [[1,2],[3,4],[5,6]]. Fast views, no copying, perfect for large numpy arrays and indexing.

1 answer 1 view
ProgrammingImplement Undo Redo in C++ Gap Buffer Text Editor

Step-by-step guide to implement undo and redo functionality in a C++ text editor using gap buffer data structure. Beginner tips, code examples, best practices, and performance optimization for efficient editing.

1 answer 1 view