# Team Lead/ Tech Lead Interview Questions and Answers

**Ques:- What is Mirrored on-line Redo Log ?**

**Ques:- What is Partial Backup ?**

**Ques:- Which of the following statements is true considering OOP (Object Oriented Programming)?**

**Recent Answer**: :

Option D : Duplicate or Redundant Data.

**Ques:- Vankins Mile is a solitaire game played on an n X n square grid. The player starts by placing a token on any square of the grid. Then on each turn, the player moves the token either one square to the right or one square down. The game ends when…**

**Recent Answer**: :

Vankin’s Mile is an American solitaire game played on an n ? n square grid. The

player starts by placing a token on any square of the grid. Then on each turn, the player moves

the token either one square to the right or one square down. The game ends when player moves

the token o the edge of the board. Each square of the grid has a numerical value, which could be

positive, negative, or zero. The player starts with a score of zero; whenever the token lands on a

square, the player adds its value to his score. The object of the game is to score as many points

as possible. For example, given the grid below, the player can score 8 − 6 + 7 − 3 + 4 = 10 points

by placing the initial token on the in the second row, and then moving down, down, right, down,

down. (This is not the best possible score for this grid of numbers.)

(a) Describe and analyze an ecient algorithm to compute the maximum possible score for a game

of Vankin’s Mile, given the n × n array of values as input.

(b) In the European version of this game, appropriately called Vankin?s Kilometer, the player

can move the token either one square down, one square right, or one square left in each turn.

However, to prevent infinite scores, the token cannot land on the same square more than

once. Describe and analyze an ecient algorithm to compute the maximum possible score for

a game of Vankin’s Kilometer, given the n × n array of values as input.

**Ques:- Reverse the words in a sentence. The string “have a nice day” should be changed to “day nice a have”.**

**Recent Answer**: :

str=’Have a nice day’

new_str=str.split(‘ ‘);

final_str=[]

for(let i = new_str.length-1;i>=0; i–){

final_str.push(new_str[i])

// console.log(i );

}

console.log(final_str.join(‘ ‘));

**Ques:- Write a program to swap to integer pointers**

**Recent Answer**: :

arr=[2,3,4,5]

for(let i =0; i<arr.length; i++){

for(let j =i+1; j<arr.length; j++){

if(arr[i]+arr[j]==8){

// console.log(arr[i],arr[j]);

temp=arr[i]

arr[i]=arr[j]

arr[j]=temp

}

}

}

console.log(arr)

**Ques:- Merge two binary search trees into one**

**Ques:- To write a function which given two dates, checks whether the dates are exactly 1 month apart(e.g June 06 2011 & July 06 2011, Dec 15 2010 & Jan 15 2011 ), less than 1 month apart(e.g Mar 01 2011 & Mar 25 2011, Jun 20 2011 & July 1…**

**Ques:- Given a set of N lines of English language, each comprises only of a-z and A-Z. For each line, find the alphabets which have highest frequency of occurance and print them (with capital letters first then small letters in increasing order in their …**

**Ques:- Given a number x, find the smallest prime number which is greater than x.**

**Recent Answer**: :

x=153

y=x*2

arr=[]

for(i=x+1; i<y;i++){

temp=true

for(j=2; j<i;j++){

if(i%j==0){

temp=false

}

}

if(temp==true){

arr.push(i)

}

}

console.log(arr[0]);

**Ques:- There was a party.there was a log register in which entry and exit time of all the guests was logged.you have to tell the time at which there was maximum guest in the party. input will be the entry and exit time of all the n guests [1,4] [2,…**

**Ques:- Given a file and and API containing getline() to read lines from it, how will u print only the unique lines from it.**

**Ques:- As we know that each user has only 4 digit acc. no. We have billions of user what is maximum bounds on these no. What algo used to generate 4 digit unique no. & what are the possible 4 digit nos. we can have…**

**Ques:- Consider a datagrid in windows application. Here item, rate, qty, amount field are there. When user enters rate and qty, amount should be automatically calculated. When enter key is pressed, the cursor should go from item to rate and then qty and then amo**

**Ques:- 3 divides 111 , 13 divides 111111 etc.. find a number having all one's which is shortest divisible by a given number which has 3 as its last digit.**

**Recent Answer**: :

111

**Ques:- What are the different ways to say, the value of x can be either a 0 or a 1. Apparently the if then else solution has a jump when written out in assembly.**

**Ques:- Write a C function for unsigned power(double x, unsigned int n) using minimum number of multiplications. Count the number of multiplications used.**

**Ques:- I have an array consisting of 2n+1 elements. n elements in it are married, i.e they occur twice in the array, however there is one element which only appears once in the array. I need to find that number in a single pass using constant memory. {a…**

**Ques:- Create a fast cached storage mechanism that, given a limitation on the amount of cache memory, will ensure that only the least recently used items are discarded when the cache memory is reached when inserting a new item. It supports 2 functions: S…**

**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…**

**Recent Answer**: :

To merge the two sorted halves of an integer array in place, you can use a modified version of the merge step in the merge sort algorithm. The idea is to start merging the two halves from the end of the array, so that there is no need for additional space.

Here’s a C++ implementation of the function:

cpp

Copy code

#include

void mergeSortedHalves(int arr[], int size) {

int i = (size / 2) – 1; // Last index of the first half

int j = size – 1; // Last index of the array

int k = size – 1; // Last index of the merged array

while (i >= 0 && j >= size / 2) {

if (arr[i] >= arr[j]) {

arr[k] = arr[i];

i–;

} else {

arr[k] = arr[j];

j–;

}

k–;

}

// Copy any remaining elements from the first half to the merged array

while (i >= 0) {

arr[k] = arr[i];

i–;

k–;

}

// The second half is already in its correct position

// Print the merged array

for (int m = 0; m < size; m++) {

std::cout << arr[m] << " ";

}

std::cout << std::endl;

}

int main() {

int arr[] = {1, 3, 6, 8, -5, -2, 3, 8};

int size = sizeof(arr) / sizeof(arr[0]);

mergeSortedHalves(arr, size);

return 0;

}

In this implementation, the mergeSortedHalves function takes an integer array arr and its size size as input. It assumes that the first half and second half of the array are already sorted.

The function initializes three pointers: i pointing to the last element of the first half, j pointing to the last element of the array, and k pointing to the last position of the merged array. It starts comparing elements from both halves and places the larger element at the position k in the merged array. The corresponding pointer is then decremented, and k is also decremented.

After merging the elements from the first half, the function copies any remaining elements from the first half to the merged array.

Finally, it prints the merged array.

Output:

diff

Copy code

-5 -2 1 3 3 6 8 8

**Ques:- A sequence of numbers is coming … a) find in constant time if a number has already come b) find in constant time how many time a number has come**

**Ques:- Consider a scenario where lots of objects are created in runtime and soon after the execution starts, you have millions of objects consuming 90% of JVM memory. What would you do about it?**

**Ques:- You have given a positive number you have to find a number which is bigger than that by using same digits available in the number. Example :- You have given a number 7585 , your output should be 7855 .**

**Ques:- Implement function to find needle from a haystack. Interviewer was looking for coding skills.**

**Recent Answer**: :

#include

using namespace std;

int find(string needle, string haystack) {

int i, j;

for (i=0; i<haystack.size(); i++) { // i is my index for caterpillar

for (j=0; j<needle.size(); j++) { // j is my index for pill

if (i+j < haystack.size ()) {

if (haystack[i+j] != needle[j]) {

break;

}

}

}

return i;

}

return -1;

}

int main(){

cout << find("pill", "caterpillar") << endl;

}

**Ques:- Function to get count of primes in range 1..n**

**Ques:- Write a logic to add the digits of an integer, get the sum and again add the digits of the resulted sum. Keep on doing this until the sum reaches to single digit. Ex: number : 3456257672 sum of digits:47 result sum : 47 sum of …**

**Ques:- How you will find the lowest common ancestor(LCA) in Binary Tree..its clear its Binary Tree not The4 Binary Search Tree ??**

**Ques:- Prove The Time Complexity of Sieve of Eratosthenes (prime generation algorithm()) is O(nlog(logn))..Interview wants from clean Mathematical Proof..for this..**

**Ques:- Which of the following is TRUE about the declaration const char * p a. the pointer cannot be changed but the value to which it points can be changed b. the value is constant but the pointer can be changed c. neither the value nor…**

**Ques:- Suppose a matrix A (M*N) is given . And A is defined as ..**

Recent Answer: Added by DK BOSS On 2021-07-21 15:26:24:If an online redo log file of a group is lost, the database remains in operation. … Oracle then uses the remaining member (or members) of this group to log the database changes.