Pairs & Tuples

Group multiple values without custom structs. Learn pairs for coordinates and tuples for returns.

53 lessons
209 min

Lessons

1. Intro

Section Overview

4m

2. What is a Pair?

Basic concept

4m

3. Creating Pairs

Construction methods

5m

4. Accessing Elements

Reading values

4m

5. Quiz: Pair Access

Knowledge check

3m1 problems

6. Comparing Pairs

How operators work

4m

7. Pairs in Vectors

Storing multiple pairs

5m

8. Quiz: Two-value container

Two-value container

3m1 problems

9. Sorting Pairs

Automatic ordering

5m

10. Quiz: Sorting Pairs

Knowledge check

3m1 problems

11. Pairs with Maps

Key-value pairs

4m

12. What is a Tuple?

Beyond two elements

4m

13. Quiz: Two-value container

Two-value container

3m1 problems

14. Creating Tuples

Construction syntax

4m

15. Quiz: Tuple Creation

Knowledge check

3m1 problems

16. Accessing Tuple Elements

Compile-time indexing

4m

17. Structured Bindings

Automatic extraction

4m

18. Tuple Comparison

Ordering rules

4m

19. Quiz: Tuple Comparison

Knowledge check

3m1 problems

20. Tie Function

Assign to existing variables

4m

21. Pair vs Tuple vs Struct

Choosing the right tool

5m

22. Quiz: Two-value container

Two-value container

3m1 problems

23. Returning Multiple Values

Common pattern

4m

24. Quiz: Return Values

Knowledge check

3m1 problems

25. Coordinates and Points

Geometric applications

4m

26. Graph Edges

Representing connections

4m

27. Priority Queue with Pairs

Storing priorities

4m

28. Quiz: Use Cases

Knowledge check

3m1 problems

29. Map Iteration Patterns

Clean map traversal

4m

30. Nested Pairs

When to stop

4m

31. Quiz: Two-value container

Two-value container

3m1 problems

32. Const Correctness

Avoiding copies

4m

33. Quiz: References

Knowledge check

3m1 problems

34. Swap and Assignment

Modifying pairs

4m

35. Type Deduction Gotchas

Common mistakes

4m

36. Quiz: Two-value container

Two-value container

3m1 problems

37. Practice: Coordinate Sorting

Exercise

4m

38. Practice: Map Statistics

Exercise

4m

39. Quiz: Key-value storage

Key-value storage

3m1 problems

40. Practice: Multi-Value Return

Exercise

4m

41. Problem - Arrival of the General

Rearranging soldiers

4m1 problems

42. General - The Pattern

Paired information

4m

43. General - Algorithm

Breaking it down

5m

44. Quiz: Two-value container

Two-value container

3m1 problems

45. General - Implementation

Complete solution

7m1 problems

46. Lessons from General

summary

4m

47. Problem - George and Accommodation

Room availability

4m1 problems

48. George - The Pattern

Simple filtering

4m

49. George - Algorithm

Breaking it down

4m

50. Quiz: Two-value container

Two-value container

3m1 problems

51. George - Implementation

Complete solution

7m1 problems

52. Lessons from George

summary

4m

53. Section Recap

What we learned

5m

Ready to start learning?

Access all 53 lessons with interactive content and progress tracking.