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.
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.
🟩 “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.
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 reverse_words(sentence):
words = sentence.strip().split()
return ‘ ‘.join(reversed(words))
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;
}
int main() {
char sentence[] = “have a nice day”;
reverse_words(sentence);
return 0;
}
✅ Output:
day nice a have
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;
}
✅ Output:
Before swap: *p1 = 10, *p2 = 20
After swap: *p1 = 20, *p2 = 10
You can merge two BSTs efficiently in three main steps:
🔧 Steps:
-
Do inorder traversal of both BSTs to get two sorted arrays.
-
Merge the two sorted arrays into one.
-
Build a balanced BST from the merged sorted array.
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.
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”)
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.
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
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.
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;
}
✅ 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
🧠 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);
}
}
✅ 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)
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:
-
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!
🔢 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).
-
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)
-
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 */ }
}
}
-
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.
You can use a simple BFS or modular trick to find the smallest such number without generating huge strings.
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;
}
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.
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;
}
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
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.
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.
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)
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!