Find Interview Questions for Top Companies
1 Comments 12 Views
Ques:- What is a mirrored online redo log?
Right Answer:

A mirrored online redo log is a duplicate copy of the redo log files maintained on a separate disk. It ensures data is not lost if one log file becomes corrupt or the disk fails — enhancing database reliability.

0 Comments 4 Views
Ques:- What is a partial backup?
Right Answer:

A partial backup saves only selected files, folders, or database parts instead of the entire system — useful for saving time and storage when full backup isn’t needed.

2 Comments 7 Views
Ques:- Which of the following statements is true considering OOP (Object Oriented Programming)?
Right Answer:

🟩 “OOP allows for encapsulation, inheritance, and polymorphism.”

These are the three core principles of OOP:

  • ✔️ Encapsulation: Bundling data and methods operating on that data into a single unit (class), and restricting direct access to some components.

  • ✔️ Inheritance: One class (child) can inherit attributes and methods from another (parent).

  • ✔️ Polymorphism: The ability for different classes to respond to the same method name in different ways.

If you provide the specific list of options, I can identify exactly which statement is correct.

1 Comments 5 Views
Ques:- Vankin’s Mile is played on an n×n grid. Starting at any cell, you can move only right or down, collecting the value at each cell. The goal is to reach the bottom-right cell with the maximum total score. How do you solve this?
Right Answer:

Use Dynamic Programming to compute the maximum score from each cell.

✅ Python Solution (Top-down with memoization):

def max_score(grid):
n = len(grid)
dp = [[-1]*n for _ in range(n)]

def dfs(i, j):
if i >= n or j >= n:
8 Comments 9 Views
Ques:- How do you reverse the words in a sentence like “have a nice day” to become “day nice a have”?
Right Answer:

def reverse_words(sentence):
words = sentence.strip().split()
return ‘ ‘.join(reversed(words))

Explanation:

s = “have a nice day”
print(reverse_words(s)) # Output: “day nice a have”

✅ C Version:

#include <stdio.h>
#include <string.h>

void reverse_words(char* str) {
char* words[100];
int count = 0;

cpp
char* token = strtok(str, " ");
while (token != NULL) {
words[count++] = token;
token = strtok(NULL, " ");
}

for (int i = count - 1; i >= 0; i--) {
printf("%s", words[i]);
if (i > 0) printf(" ");
}
printf("\n");

}

int main() {
char sentence[] = “have a nice day”;
reverse_words(sentence);
return 0;
}

✅ Output:
day nice a have

1 Comments 4 Views
Ques:- How do you swap two integer pointers in C?
Right Answer:

You need a function that accepts the addresses of the pointers (i.e., int**), and then swaps them.

✅ C Code:

#include <stdio.h>

void swapPointers(int** a, int** b) {
int* temp = *a;
*a = *b;
*b = temp;
}

int main() {
int x = 10, y = 20;
int* p1 = &x;
int* p2 = &y;

perl
printf("Before swap: *p1 = %d, *p2 = %d\n", *p1, *p2);
swapPointers(&p1, &p2);
printf("After swap: *p1 = %d, *p2 = %d\n", *p1, *p2);

return 0;

}

✅ Output:

Before swap: *p1 = 10, *p2 = 20
After swap: *p1 = 20, *p2 = 10

0 Comments 7 Views
Ques:- How do you merge two Binary Search Trees (BSTs) into a single BST while maintaining sorted order?
Right Answer:

You can merge two BSTs efficiently in three main steps:

🔧 Steps:

  1. Do inorder traversal of both BSTs to get two sorted arrays.

  2. Merge the two sorted arrays into one.

  3. Build a balanced BST from the merged sorted array.

Explanation:

Python Example:

def inorder(root, res):
if root:
inorder(root.left, res)
res.append(root.val)
inorder(root.right, res)

def merge_sorted_lists(list1, list2):
i = j = 0
merged = []
while i < len(list1) and j < len(list2):
if list1[i] < list2[j]:
merged.append(list1[i])
i += 1
else:
merged.append(list2[j])
j += 1
merged.extend(list1[i:])
merged.extend(list2[j:])
return merged

def sorted_array_to_bst(arr):
if not arr:
return None
mid = len(arr) // 2
node = TreeNode(arr[mid])
node.left = sorted_array_to_bst(arr[:mid])
node.right = sorted_array_to_bst(arr[mid+1:])
return node

def merge_bsts(root1, root2):
list1, list2 = [], []
inorder(root1, list1)
inorder(root2, list2)
merged = merge_sorted_lists(list1, list2)
return sorted_array_to_bst(merged)

✅ Time Complexity: O(n + m)
✅ Space Complexity: O(n + m)
Where n and m are the number of nodes in the two BSTs.

0 Comments 8 Views
Ques:- Write a function that, given two dates, checks whether they are: ✅ exactly 1 month apart ✅ less than 1 month apart ✅ more than 1 month apart
Right Answer:

from datetime import datetime
from dateutil.relativedelta import relativedelta

def check_month_difference(date1_str, date2_str):
date1 = datetime.strptime(date1_str, “%b %d %Y”) # e.g., “Jun 06 2011”
date2 = datetime.strptime(date2_str, “%b %d %Y”)

bash
# Ensure date1 is earlier
if date1 > date2:
date1, date2 = date2, date1

# Check exactly 1 month apart
one_month_later = date1 + relativedelta(months=1)
if one_month_later.date() == date2.date():
return "Exactly 1 month apart"

# Check less than 1 month
if date2 < one_month_later:
return "Less than 1 month apart"
else:
return "More than 1 month apart"

Explanation:

check_month_difference(“Jun 06 2011”, “Jul 06 2011”) → “Exactly 1 month apart”
check_month_difference(“Mar 01 2011”, “Mar 25 2011”) → “Less than 1 month apart”
check_month_difference(“Jan 15 2011”, “Mar 01 2011”) → “More than 1 month apart”

📦 Requires: pip install python-dateutil
Let me know if you want a C/C++ version or want to include day/month boundaries more strictly.

0 Comments 9 Views
Ques:- Given N lines of text (with only a-z and A-Z), for each line, print the alphabet characters with the highest frequency — sorted with capital letters first (A-Z), then lowercase (a-z).
Right Answer:

def process_lines(lines):
for line in lines:
freq = [0] * 52 # 0–25: A-Z, 26–51: a-z
for ch in line:
if ‘A’ <= ch <= ‘Z’:
freq[ord(ch) – ord(‘A’)] += 1
elif ‘a’ <= ch <= ‘z’:
freq[ord(ch) – ord(‘a’) + 26] += 1

perl
max_freq = max(freq)
result = []

# Capital letters A-Z
for i in range(26):
if freq[i] == max_freq:
result.append(chr(i + ord('A')))
# Small letters a-z
for i in range(26, 52):
if freq[i] == max_freq:
result.append(chr(i - 26 + ord('a')))

print(''.join(result))

Explanation:

Input:
lines = [
“aAb”,
“abcABCabc”,
“ZzZzZz”
]

Output:
A a
a b c A B C
Z z

✅ Time Complexity: O(N × L), where N = number of lines, L = length of each line
✅ Space: O(1) for frequency array

Let me know if you need a C++ version or file input handling.

3 Comments 7 Views
Ques:- How do you find the smallest prime number greater than a given number x?
Right Answer:

You can use a simple loop and primality test:

🔧 C++-like pseudocode:

bool isPrime(int n) {
if (n < 2) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
for (int i = 3; i*i <= n; i += 2) {
if (n % i == 0) return false;
}
return true;
}

int nextPrime(int x) {
int n = x + 1;
while (!isPrime(n)) n++;
return n;
}

Explanation:

✅ Example:

Input: x = 17
Output: 19 (next prime after 17)

⏱ Time Complexity:

  • isPrime: O(√n)

  • nextPrime: Worst case O(n√n), but fast in practice

0 Comments 5 Views
Ques:- Given a list of guest entry and exit times, determine the time at which the maximum number of guests were present at the party.
Right Answer:

🧠 Idea:

  • Separate all entry and exit times

  • Sort both lists

  • Use a two-pointer technique to simulate guests entering and exiting

✅ C++-like Pseudocode:

int findPeakGuestTime(vector<pair<int, int>>& times) {
vector<int> entry, exit;
for (auto& t : times) {
entry.push_back(t.first);
exit.push_back(t.second);
}

pgsql
sort(entry.begin(), entry.end());
sort(exit.begin(), exit.end());

int guests = 0, maxGuests = 0, time = 0;
int i = 0, j = 0, n = entry.size();

while (i < n && j < n) {
if (entry[i] <= exit[j]) {
guests++;
if (guests > maxGuests) {
maxGuests = guests;
time = entry[i];
}
i++;
} else {
guests--;
j++;
}
}

return time;

}

Explanation:

✅ Example:

Input:
[1, 4], [2, 5], [9, 12], [5, 9], [5, 12]
Output:
Time with max guests: 5

⏱ Time Complexity: O(n log n)
📦 Space Complexity: O(n)

0 Comments 3 Views
Ques:- How do you print only the unique lines from a file using getline()?
Right Answer:

Use a set to store seen lines and print each only once:

#include <iostream>
#include <unordered_set>
#include <string>

void printUniqueLines(std::istream& file) {
std::unordered_setstd::string seen;
std::string line;
while (std::getline(file, line)) {
if (seen.insert(line).second) {
std::cout << line << std::endl;
}
}
}

Explanation:

✅ Explanation:

  • std::getline() reads one line at a time.

  • unordered_set stores each line if it hasn’t been seen.

  • insert() returns true only if the line is new — so you print only unique lines.

⏱ Time: O(n)
📦 Space: O(n) for storing unique lines

Let me know if you want a version in Python or C!

0 Comments 4 Views
Ques:- If each user is assigned a 4-digit account number, what’s the maximum number of unique accounts possible, and what algorithms can be used to generate unique 4-digit IDs?
Right Answer:

🔢 Total Possible 4-Digit Numbers:
→ From 0000 to 9999 = 10,000 possible values (0 to 9999)

🚫 Limitation:
You cannot assign unique 4-digit numbers to billions of users — max unique accounts = 10,000.

🔒 Why it’s limited:
4-digit number = 10⁴ = 10,000
So you can support only 10,000 users uniquely with 4-digit IDs.

📌 Algorithms (for small-scale unique assignment):

1. Counter-Based
– Start from 0000, increment for each user
– Keep a record of assigned numbers

2. Shuffled Pool
– Pre-generate all 4-digit numbers, shuffle them
– Assign randomly from the pool to avoid patterns

3. Hashing (Not safe here)
– Hashing can cause collisions; not recommended for strict uniqueness in small space

✅ Real-World Recommendation:
If you have billions of users, use longer IDs (e.g. 8 or 10 digits) or include a prefix/suffix system (e.g., region + 4-digit ID).

Explanation:
  • Max unique 4-digit numbers: 10,000

  • Not scalable for billions

  • Use simple increment or shuffled list for assigning

  • For large scale: increase ID length or use composite keys (e.g. 3-digit region + 4-digit local ID)

0 Comments 1 Views
Ques:- In a Windows Forms DataGridView with columns: Item, Rate, Qty, Amount — how can we auto-calculate Amount (Rate × Qty) and set Enter key navigation order: Item → Rate → Qty → Amount?
Right Answer:
  1. Auto-calculate Amount:
    In the CellValueChanged or CellEndEdit event of DataGridView:

private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == rateCol || e.ColumnIndex == qtyCol)
{
try
{
var rate = Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[“Rate”].Value);
var qty = Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[“Qty”].Value);
dataGridView1.Rows[e.RowIndex].Cells[“Amount”].Value = rate * qty;
}
catch { /* handle conversion errors */ }
}
}

  1. Enter key navigation (override default behavior):
    In the EditingControlShowing event:

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBox tb = e.Control as TextBox;
if (tb != null)
{
tb.KeyDown -= TextBox_KeyDown;
tb.KeyDown += TextBox_KeyDown;
}
}

Then in the handler:

private void TextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.Handled = true;
SendKeys.Send(“{TAB}”); // Move to next cell
}
}

✅ Result:

  • When Rate or Qty is entered → Amount auto-updates.

  • Enter key behaves like Tab → moves cell focus forward in the desired order.

1 Comments 6 Views
Ques:- What is the smallest number made of only 1’s (like 1, 11, 111, …) that is divisible by a given number N (where N ends with the digit 3)?
Right Answer:

You can use a simple BFS or modular trick to find the smallest such number without generating huge strings.

Explanation:

We want the smallest number like 1, 11, 111, 1111… divisible by N.
Let’s try appending 1’s while taking modulo N at each step to keep values small.

✅ Efficient C++-style logic (works for N ending in 3, or any N):

Here’s a conceptual algorithm in C-like pseudocode:

int find_min_ones_divisible(int N) {
int rem = 1 % N;
int len = 1;
std::set<int> visited;

kotlin
while (rem != 0) {
if (visited.count(rem)) return -1; // loop detected
visited.insert(rem);
rem = (rem * 10 + 1) % N;
len++;
}
return len;

}

0 Comments 4 Views
Ques:- What are different ways to assign x to either 0 or 1 without using an if-else (to avoid jumps in assembly)?
Right Answer:

To avoid branching (like if-else), use bitwise or arithmetic operations.

Here are clean, branchless alternatives:

🔸 1. Use Boolean expression directly:

x = (condition != 0); // Result is 0 or 1
// Example:
x = (a > b); // x becomes 1 if true, 0 if false

🔸 2. Use bit masking:

x = (condition & 1);
// Useful if condition may produce a value other than 0 or 1, ensures it’s just 1 bit

🔸 3. Use ternary operator (may or may not compile without jump):

x = condition ? 1 : 0;

Note: Some compilers optimize ternary expressions into branchless code; others don’t. Boolean casts and bitwise operations are most reliable for jump-free output in assembly.

🎯 Goal:
Prefer (x = !!condition) or (x = condition != 0) for clean, branch-free code.

0 Comments 2 Views
Ques:- Write a C function to compute unsigned power (xⁿ) using minimal multiplications. Also count how many multiplications are performed.
Right Answer:

Use the fast exponentiation method (Exponentiation by Squaring) — reduces multiplications from O(n) to O(log n).

✅ C Code:

#include <stdio.h>

int mulCount = 0;

double power(double x, unsigned int n) {
if (n == 0)
return 1;
double half = power(x, n / 2);
mulCount++; // For half * half
if (n % 2 == 0)
return half * half;
else {
mulCount++; // For (half * half) * x
return half * half * x;
}
}

int main() {
double x = 2.0;
unsigned int n = 10;
mulCount = 0;
double result = power(x, n);
printf(“Result: %.2f\n”, result);
printf(“Multiplications: %d\n”, mulCount);
return 0;
}

Explanation:

Result: 1024.00
Multiplications: 5

✅ Key Notes:

  • Time complexity: O(log n)

  • Space complexity: O(log n) due to recursion

  • Minimal multiplications using divide & conquer strategy

0 Comments 2 Views
Ques:- How do you find the single non-repeated number in an array where every other number appears exactly twice, using one pass and constant space?
Right Answer:

Use XOR (^) operation.

✅ Python Code:

def find_single(arr):
result = 0
for num in arr:
result ^= num
return result

✅ Explanation:

  • XOR of a number with itself is 0 → (a ^ a = 0)

  • XOR of a number with 0 is the number → (0 ^ b = b)

  • So all pairs cancel out, and you’re left with the unpaired number.

Explanation:

arr = [1, 3, 5, 3, 1, 7, 5]
print(find_single(arr)) # Output: 7

⏱ Time: O(n)
📦 Space: O(1)
🧠 Only 1 pass through the array needed.

0 Comments 2 Views
Ques:- How do you implement a fast cache that removes the least recently used items when full?
Right Answer:

Use a HashMap + Doubly Linked List:

  • HashMap stores key → node for O(1) access

  • Doubly Linked List tracks usage order

  • On get/put: move item to front

  • On put (if full): remove tail (least recently used)

⏱ Time: O(1) for both get() and put()
📦 Space: O(capacity)

1 Comments 2 Views
Ques:- Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space]. e.g. If input array is [1,3,6,8,-5,-2,3,8] It should…
Right Answer:

You’re given an array where:

  • The first half (A[0 to n/2 – 1]) is sorted

  • The second half (A[n/2 to n – 1]) is sorted

  • You need to merge both into a fully sorted array in-place (without using extra arrays)



The Team Lead / Tech Lead category on justcrackinterview.com is designed for professionals aspiring to step into or grow within leadership roles in the tech industry. Whether you’re an experienced developer preparing to lead a team or an existing lead refining your skills for your next big interview, this section gives you a 360° preparation path.

Leading a team is not just about technical expertise — it’s about communication, delegation, conflict resolution, mentoring, sprint planning, and decision-making under pressure. Our curated content includes real-world leadership scenarios, commonly asked leadership interview questions, and tips to showcase your management style with impact.

This section covers crucial areas such as:

  • People management & team dynamics

  • Agile methodology & sprint planning

  • Project ownership & accountability

  • Code reviews & quality standards

  • Cross-functional collaboration

  • Stakeholder communication

  • Technical vision & decision-making

Each module includes scenario-based questions and sample answers that reflect what top companies expect from their tech leaders. You’ll also learn how to demonstrate emotional intelligence, problem-solving, and ownership — key traits of successful leads.

If you’re preparing for roles like Technical Lead, Team Lead, Engineering Manager, or Senior Developer, this content is tailored for you. Whether the interview is behavioral, technical, or managerial — we help you answer with structure and confidence.

At Just Crack Interview, we don’t just prepare you to code — we prepare you to lead. Step into your next leadership role fully prepared!