ARRAYLIST MASTER PRACTICE – 60 QUESTIONS (WITH CODE & OUTPUT)
PART 1: 20 TRICKY OUTPUT QUESTIONS
Q1–Q20 focus on remove(), iteration traps, subList views, references, sorting, rotation, null
handling.
PART 2: 20 MEDIUM DSA PROBLEMS
Q21–Q40 cover:
- Remove duplicates
- Second largest
- Rotation
- Palindrome
- Zero movement
- Leaders
- Union / Intersection / Difference
- Kth largest
- Merge sorted lists
- LIS length
- Kadane
- Pair sum
- Consecutive duplicates
- Sorted check
- Majority element
- Split list
- Alternate merge
PART 3: 20 HARD LOGIC + PATTERN PROBLEMS
Q41–Q60 include:
- Zig-zag reorder
- Wave form
- Prefix max
- Running sum
- Equilibrium index
- Alternate positive-negative
- Product except self
- Remove every k-th
- Mountain array
- Block reverse
- Longest consecutive sequence
- Prefix / Suffix arrays
- Frequency pyramid
- Stock buy-sell
- Maximum product subarray
- Diamond pattern
NOTE:
All problems are written in Java using ArrayList.
Each problem includes:
- Code
- Exact Output
Use this PDF for:
✔ Exams
✔ Interviews
✔ Hands-on practice
✔ Deep understanding of Java Collections
(Refer to your ChatGPT conversation for full code listings from Q1 to Q60 in order.)