BTI Beyond The Interviews

Career & Behavioral · 6 sections

Campus OA & Output Prediction

Campus online assessments end to end: timing strategy, fast I/O, overflow and maths shortcuts, plus the JavaScript, Python and Java output-prediction tricks that decide the MCQ round.

Free · full sheet 47 cards Updated 24 Oct 2026

OA Strategy

Typical OA structure at Indian product companies?

60-90 minutes: 2-3 coding problems (Easy-Med-Hard), sometimes 10-20 MCQs (DSA output, OS, DBMS, CN, aptitude). Partial scores count, because test cases are scored individually. (Easy)

Strategy when the clock is running?

Read all problems first. Solve the easiest fully, then brute-force the others to collect partial test cases, then optimise. Watch the constraints for the intended complexity. (Easy)

Common OA pitfalls?

Not handling n = 0/1, duplicates, negative numbers, integer overflow, off-by-one in binary search, printing extra spaces or debug output, reading input in the wrong format. (Easy)

Proctoring rules to respect?

Webcam on, no tab switching (often logged), no second screen or phone. Plagiarism checks compare code across candidates, so even "similar" code gets flagged. Write your own. (Easy)

Night-before checklist for the OA?

Test your laptop, webcam and internet, have a backup hotspot, keep a language template ready (fast I/O, typedefs), revise 10 patterns (Deck 7), sleep. Log in 15 minutes early. (Easy)

Code Speed & Math

Fast I/O in C++/Java/Python?

C++: `ios::sync_with_stdio(false); cin.tie(nullptr);`. Java: `BufferedReader` + `StringTokenizer` (or DataInputStream). Python: `input = sys.stdin.readline`. Use `print` with join. (Easy)

// C++
ios::sync_with_stdio(false); cin.tie(nullptr);

// Python
import sys
input = sys.stdin.readline

Why use `long long` / `long`, and when?

Sums and products past 2.1×10⁹ overflow int. 10⁵ × 10⁹ = 10¹⁴ needs 64-bit. Take mod 1e9+7 after each multiplication: `(a*b)%MOD` with 64-bit operands. (Easy)

const long long MOD = 1e9 + 7;
long long r = (a * b) % MOD;  // 64-bit operands

Python: recursion error in DFS on 10⁵ nodes?

The default recursion limit is ~1000. Use `sys.setrecursionlimit(10**6)` (and possibly threading with a larger stack), or convert to an iterative stack. (Med)

import sys
sys.setrecursionlimit(10**6)

Fast modular exponentiation?

Binary exponentiation, O(log b). (Python has a built-in `pow(a, b, m)`.) (Easy)

def power(a, b, m):
    r = 1; a %= m
    while b:
        if b & 1: r = r * a % m
        a = a * a % m; b >>= 1
    return r

Sieve of Eratosthenes complexity?

O(n log log n). Mark multiples starting from i², loop i up to √n. Good for n ≤ 10⁷. (Easy)

is_prime = [True] * (n + 1)
for i in range(2, int(n ** 0.5) + 1):
    if is_prime[i]:
        for j in range(i * i, n + 1, i):
            is_prime[j] = False

nCr mod p for many queries?

Precompute factorials and inverse factorials (Fermat: inv = a^(p−2) mod p for prime p). Then nCr = fact[n]·inv[r]·inv[n−r]. O(1) per query. (Med)

fact[0] = inv[0] = 1
for i in range(1, n + 1):
    fact[i] = fact[i - 1] * i % p
inv[n] = pow(fact[n], p - 2, p)
for i in range(n, 0, -1):
    inv[i - 1] = inv[i] * i % p
# nCr = fact[n] * inv[r] % p * inv[n - r] % p

Aptitude: a train 150 m long at 54 km/h crosses a pole in?

54 km/h = 15 m/s, so 150/15 = 10 s. (km/h × 5/18 = m/s.) (Easy)

km/h * 5/18 = m/s
54 * 5/18 = 15 m/s
150 / 15 = 10 s

MCQ Rapid Fire

OS MCQ favourite: process vs thread?

A process has its own address space. Threads share memory, heap and files within a process but have their own stack and registers. Thread context switches are cheaper. (Easy)

DBMS MCQ favourite: normal forms in one line each?

1NF atomic values. 2NF no partial dependency on part of a composite key. 3NF no transitive dependency. BCNF every determinant is a candidate key. (Easy)

1NF -> atomic
2NF -> no partial dependency
3NF -> no transitive dependency
BCNF -> every determinant is a candidate key

CN MCQ favourite: TCP vs UDP?

TCP: connection-oriented, reliable, ordered, flow and congestion control (HTTP/1.1, HTTP/2). UDP: connectionless, no guarantees, low latency (DNS, video, QUIC/HTTP/3 builds reliability on top of UDP). (Easy)

Output: JavaScript

Output order?

**1 4 3 2**. Sync code runs first, then the microtask queue (promises), then macrotasks (timers).

console.log(1);
setTimeout(() => console.log(2));
Promise.resolve().then(() => console.log(3));
console.log(4);

What does this log?

**3 3 3**. `var` is function-scoped, so there is one shared `i`. With `let` the output is **0 1 2** — a new binding per iteration.

for (var i = 0; i < 3; i++) setTimeout(() => console.log(i));

What is the output?

**[1, 10, 2]**. The default sort compares elements as strings. Use `.sort((a, b) => a - b)` for numeric order.

[10, 1, 2].sort()

What do these return?

`"object"` (a historic bug), `"number"`, `"object"` (use `Array.isArray` to detect arrays).

typeof null
typeof NaN
typeof []

What are the results?

**false, true**. `==` has special null/undefined rules (`null` only equals `undefined`), while relational operators convert `null` to `0`.

null == 0
null >= 0

What are the results? — `"5" - 2`

`3`, `"52"`, `0`. `-` coerces to number; `+` with a string concatenates; unary `+` converts to number.

"5" - 2
"5" + 2
+""

Which comparisons are true?

`false, true, true, -1`. `includes` uses SameValueZero; `indexOf` uses `===`.

NaN === NaN
Object.is(NaN, NaN)
[NaN].includes(NaN)
[NaN].indexOf(NaN)

What happens?

**ReferenceError**. The inner `x` is hoisted but sits in the temporal dead zone until its declaration.

let x = 1;
{
  console.log(x);
  let x = 2;
}

What are the two lengths?

**2 vs 1**. `.length` counts UTF-16 code units; spreading iterates code points.

"\u{1F44D}".length
[..."\u{1F44D}"].length

What do `o.f()` and `o.g()` return?

`undefined`, `1`. Arrow functions take `this` from the enclosing scope, not from the object.

const o = {
  n: 1,
  f: () => this.n,
  g() { return this.n; }
};
o.f();
o.g();

What gets logged?

A **Promise** (fulfilled with `1`), not `1`. Use `await f()` or `.then`.

async function f() { return 1; }
console.log(f());

Is this true, and how do you compare safely?

`false` — the sum is `0.30000000000000004`. Compare with `Math.abs(a - b) < Number.EPSILON`, or use integer paise for money.

0.1 + 0.2 === 0.3

Output: Python

What does this print?

**[2, 2, 2]**. Late binding: closures look up `i` at call time. Fix with `lambda i=i: i`.

fs = [lambda: i for i in range(3)]
print([f() for f in fs])

What does this print? — `a = [[0] * 3] * 3`

`[[1, 0, 0], [1, 0, 0], [1, 0, 0]]`. The three rows are the same list object. Use `[[0] * 3 for _ in range(3)]`.

a = [[0] * 3] * 3
a[0][0] = 1
print(a)

What does this print? — `print(-7 // 2, -7 % 2)`

**-4 1**. Floor division rounds towards −∞, and `%` takes the sign of the divisor (C and Java give `-3, -1`).

print(-7 // 2, -7 % 2)

What does this print? — `print(round(2.5), round(3.5))`

**2 4**. Banker's rounding (round half to even).

print(round(2.5), round(3.5))

What does this print? — `d = {1: 'a', True: 'b', 1.0: 'c'}`

**{1: 'c'}**. `1 == True == 1.0` and they hash the same, so the first key object is kept and the value is overwritten.

d = {1: 'a', True: 'b', 1.0: 'c'}
print(d)

What happens? — `t = (1, [2])`

Raises **TypeError**, yet `t` is now `(1, [2, 3])`. `+=` mutates the list in place first, then the tuple item assignment fails.

t = (1, [2])
t[1] += [3]

What does `f()` return?

**2**. `finally` overrides the return. Python 3.14 emits a **SyntaxWarning** for `return`/`break`/`continue` in `finally` (PEP 765).

def f():
    try:
        return 1
    finally:
        return 2

What does this print? — `print(all([]), any([]))`

**True False** — vacuous truth.

print(all([]), any([]))

What do these print?

`''` and `'abc'`, because slices clamp. `s[10]` raises `IndexError`.

s = "abc"
print(s[10:], s[-10:])
print(s[10])

What does this print? — `x = [3, 1, 2]`

**None**. `list.sort()` sorts in place and returns `None`; `sorted(x)` returns a new list.

x = [3, 1, 2]
y = x.sort()
print(y)

What are the two types?

`<class 'int'>`, `<class 'tuple'>`. The comma makes the tuple, not the parentheses.

print(type((1)), type((1,)))

Output: Java

What does this print? — `System.out.println("a" + 1 + 2);`

**a12** and **3a**. Evaluation is left to right; arithmetic happens only until a String appears.

System.out.println("a" + 1 + 2);
System.out.println(1 + 2 + "a");

What does this print? — `int x = 5;`

**5**. `x++` yields the old value 5, and then that 5 is assigned back over the incremented value.

int x = 5;
x = x++;
System.out.println(x);

What does this print? — `System.out.println(Math.abs(Integer.MIN_VALUE));`

**-2147483648**. `+2³¹` overflows int. Use `Math.absExact` (throws) or cast to long.

System.out.println(Math.abs(Integer.MIN_VALUE));

Which of these compiles?

The first is a **compile error** (int to short narrowing). The second compiles, because compound assignment includes an implicit cast.

short s = 1;
s = s + 1;   // compile error
s += 1;      // ok

What do the comparisons yield?

**false, true**. Literals are pooled; `new` creates a heap object; `intern()` returns the pooled one.

String a = "hi";
String b = new String("hi");
a == b;
a == b.intern();

What happens? — `List.of(1, 2).add(3);`

Throws **UnsupportedOperationException**. `List.of` is immutable (and rejects nulls).

List.of(1, 2).add(3);

What happens in this loop?

Usually a **ConcurrentModificationException** (fail-fast iterator). Use `list.removeIf(cond)` or `Iterator.remove()`.

for (String s : list) {
    if (cond) list.remove(s);
}

What do these print? — `System.out.println(1 / 0);`

The first throws **ArithmeticException**. The second prints **Infinity** (IEEE 754).

System.out.println(1 / 0);
System.out.println(1.0 / 0);

What does this print? — `char c = 'a';`

**98** and **b**. `char + int` promotes to int; the cast converts back to a character.

char c = 'a';
System.out.println(c + 1);
System.out.println((char) (c + 1));

Want this as flashcards? Study these 47 cards recall-first in the browser — flip, answer out loud, grade yourself.

Open the card deck