---
title: "C++ vs Python"
url: https://perrotta.dev/2026/06/c-vs-python/
last_updated: 2026-06-22
---


When LeetCoding or participating in programming contests, it's worth to
highlight a few differences between C++ and Python:

```cpp
- maximum priority queue (PQ)
- `sort` with a comparison function
- ordered set / map — `O(log n)` — BST (binary search tree)
```

```python
- minimum priority queue (PQ)
- `sort` with a key function
- insertion order set / map — `O(1)` — HT (hash tree)
```

