yield instead of return. It pauses after each value and resumes exactly where it left off the next time you ask.
next() on it, it continues from the line after yield.matrix[row][col]. Today you'll transpose it, sum rows and columns, and find the diagonal.
([{}]) is valid. ([)] is not. The trick is using a Stack — a list where you only add and remove from the top (like a stack of plates). Push opening brackets on, pop when you see a closing one, check they match.
stack.append(x) → push (add to top)stack.pop() → pop (remove from top)stack[-1] → peek (look at top without removing)
"([)]" step by step on paper to understand exactly which line causes it to return False."aabcccdddd" becomes "a2bc3d4". If the compressed version is not shorter, keep the original.
describe() method in the parent class. Notice how it calls the area method, which automatically resolves to the correct child version. This demonstrates polymorphism.math module for the value of Pi. Make sure each child class is correctly overriding the parent's area method. The parent class's describe method will automatically call the correct child method.
yield, but you can get the same "one value at a time" behaviour by implementing the Iterator interface. You define hasNext() — does another value exist? — and next() — give me the next one. Java's for-each loop works with any Iterator automatically.
hasNext() condition when the internal value reaches 55 to understand when the iterator flags that it is exhausted.hasNext() check with a manual counter in a loop condition.
int[][] matrix. Access any cell with matrix[row][col], get row count with matrix.length, column count with matrix[0].length. Today you'll transpose it, sum rows and columns, and find the diagonal.
([{}]) is valid. ([)] is not. The trick is using a Stack — push opening brackets on, pop when you see a closing one, check they match. In Java, use Deque<Character> as your stack. ArrayDeque is Java's recommended stack implementation.
Deque<Character> stack = new ArrayDeque<>();stack.push(ch) → push to topstack.pop() → remove from topstack.peek() → look at top without removingstack.isEmpty() → check if empty (safer than size()==0)
"({[]})" — what should it return?"aabcccdddd" becomes "a2bc3d4". If the compressed version is not shorter, keep the original. Key Java difference: never use + to build strings inside a loop — each + creates a brand new String object in memory. Use StringBuilder instead — it modifies in place and is dramatically faster.
StringBuilder when a sequence ends.abstract keyword to force subclasses to implement a method. An abstract class cannot be instantiated directly.
function* syntax — almost identical to Python's yield. They're used in async programming, infinite sequences, and lazy data pipelines. They work the same as Python generators — pause at yield, resume on next call.
function* name() { yield value; } ← the * makes it a generatorconst gen = name(); ← creates the generator objectgen.next() ← returns { value: X, done: false }gen.next().value ← get just the value{ value: undefined, done: true }
matrix[row][col]. Bonus: you can use .map() and .reduce() for some operations instead of nested for loops — this is the idiomatic modern JS way.
reduce or map on the matrix, remember that the callback function's second argument gives you the current index, which is very handy for finding the diagonal!
([{}]) is valid. ([)] is not. The trick is using a Stack — push opening brackets on, pop when you see a closing one, check they match. JavaScript uses a regular array as the stack. .push() adds to the end, .pop() removes from the end.
pop() return if the array is already empty? Make sure you check the array's length before trying to match brackets!
"aabcccdddd" becomes "a2bc3d4". If the compressed version is not shorter, keep the original. JS strings are immutable — don't build the result with += in a loop if you can avoid it. Use an array to collect parts and join at the end.
parts array when a sequence ends.extends and super(). JS has no abstract keyword — enforce method implementation by throwing an error in the base class.
this.constructor.name operates dynamically within the parent describe() method to pull the specific class identity.% matches any number of characters, _ matches exactly one character.
% means "zero or more of anything" — like a * in search._ means "exactly one character" — any single character.| id | name | city | marks | grade |
|---|---|---|---|---|
| 1 | 'Rahul' | 'Delhi' | 72 | 'B' |
| 2 | 'Priya' | 'Mumbai' | 91 | 'A' |
| 3 | 'Arjun' | 'Delhi' | 38 | 'F' |
| 4 | 'Sneha' | 'Pune' | 85 | 'A' |
| 5 | 'Vikram' | 'Mumbai' | 55 | 'C' |
| 6 | 'Anita' | 'Delhi' | 94 | 'A' |
| 7 | 'Rohan' | 'Pune' | 43 | 'F' |
| name |
|---|
| Arjun |
| Anita |
| name |
|---|
| Priya |
| Sneha |
| Anita |
| name | city |
|---|---|
| Priya | Mumbai |
| Sneha | Pune |
| Vikram | Mumbai |
| Rohan | Pune |
% and _. One represents any number of characters, while the other represents exactly one. How can you combine them to specify exact lengths?
WHERE city = 'Delhi' OR city = 'Pune', SQL gives you IN — a cleaner way to match any value from a list. Instead of WHERE marks >= 50 AND marks <= 80, use BETWEEN — it's more readable and inclusive on both ends.
| id | name | city | marks | grade |
|---|---|---|---|---|
| 1 | 'Rahul' | 'Delhi' | 72 | 'B' |
| 2 | 'Priya' | 'Mumbai' | 91 | 'A' |
| 3 | 'Arjun' | 'Delhi' | 38 | 'F' |
| 4 | 'Sneha' | 'Pune' | 85 | 'A' |
| 5 | 'Vikram' | 'Mumbai' | 55 | 'C' |
| 6 | 'Anita' | 'Delhi' | 94 | 'A' |
| 7 | 'Rohan' | 'Pune' | 43 | 'F' |
| name | grade | marks |
|---|---|---|
| Rahul | B | 72 |
| Priya | A | 91 |
| Sneha | A | 85 |
| Anita | A | 94 |
| name | marks |
|---|---|
| Rahul | 72 |
| Vikram | 55 |
| id | name | marks | grade |
|---|---|---|---|
| 1 | 'Rahul' | 72 | 'B' |
| 2 | 'Priya' | 91 | 'A' |
| 3 | 'Arjun' | 38 | 'F' |
| 4 | 'Sneha' | 85 | 'A' |
| 5 | 'Vikram' | 55 | 'C' |
| 6 | 'Anita' | 94 | 'A' |
| 7 | 'Rohan' | 43 | 'F' |
| name | marks | band |
|---|---|---|
| Anita | 94 | Distinction |
| Priya | 91 | Distinction |
| Sneha | 85 | Distinction |
| Rahul | 72 | First Class |
| Vikram | 55 | Pass |
| Rohan | 43 | Fail |
| Arjun | 38 | Fail |
WHERE column > (SELECT AVG(column) FROM table)| id | name | city | marks | grade |
|---|---|---|---|---|
| 1 | 'Rahul' | 'Delhi' | 72 | 'B' |
| 2 | 'Priya' | 'Mumbai' | 91 | 'A' |
| 3 | 'Arjun' | 'Delhi' | 38 | 'F' |
| 4 | 'Sneha' | 'Pune' | 85 | 'A' |
| 5 | 'Vikram' | 'Mumbai' | 55 | 'C' |
| 6 | 'Anita' | 'Delhi' | 94 | 'A' |
| 7 | 'Rohan' | 'Pune' | 43 | 'F' |
| name | marks |
|---|---|
| Rahul | 72 |
| Priya | 91 |
| Sneha | 85 |
| Anita | 94 |
| name | city | marks |
|---|---|---|
| Anita | Delhi | 94 |
| Priya | Mumbai | 91 |
| Sneha | Pune | 85 |
| id | name | city | marks | grade |
|---|---|---|---|---|
| 1 | 'Rahul' | 'Delhi' | 72 | 'B' |
| 2 | 'Priya' | 'Mumbai' | 91 | 'A' |
| 3 | 'Arjun' | 'Delhi' | 38 | 'F' |
| 4 | 'Sneha' | 'Pune' | 85 | 'A' |
| 5 | 'Vikram' | 'Mumbai' | 55 | 'C' |
| 6 | 'Anita' | 'Delhi' | 94 | 'A' |
| 7 | 'Rohan' | 'Pune' | 43 | 'F' |
| name | city |
|---|---|
| Rahul | Delhi |
| Arjun | Delhi |
| Anita | Delhi |
| Rohan | Pune |
| band | count |
|---|---|
| Distinction | 3 |
| First Class | 1 |
| Pass | 1 |
| Fail | 2 |