Language Quick Reference
tags: - cocubes - coding - language
Language Quick Reference
Use this as a reminder, not a substitute for writing actual code in your chosen language.
C/C++
- Arrays are fixed-size unless using a dynamic container.
- Use a 64-bit integer type for large sums/products.
- Watch integer division: 5/2 gives 2 for integer operands.
- Strings need careful indexing and null termination in C.
- C++ standard library containers commonly help: vector, string, unordered_map, map, stack, queue, priority_queue.
Java
- Use long for large integer sums/products.
- Arrays have fixed size; ArrayList is dynamic.
- Common structures: HashMap, HashSet, ArrayDeque, PriorityQueue.
- String is immutable; use StringBuilder for repeated concatenation.
- Use equals for string value comparison, not ==.
Python
- Integers automatically grow, but still reason about complexity.
- Common structures: list, dict, set, deque, heapq.
- String slicing can make copies; avoid unnecessary repeated slicing for large input.
- Read input exactly as expected; strip newlines where needed.
All languages
- Avoid names like x1, temp2 everywhere; use clear names in coding solutions.
- Avoid printing debug statements.
- Do not rely on undefined order from unordered/hash collections unless the problem permits it.
- Test with n=0/1 where valid, repeated values and negatives.
[[05_Coding/Coding_Playbook|Coding playbook]]