23-11-20

# Aptitude

Find the missing number 2 , 3 , 7 , 8 , 13 , 14 , ?

• 24

• 21

• 18

• 20

Ans : 20

# Technical

Which of the following queries can be used to select data from one table and insert it into another? 1. SELECT ALL COPY newtable [IN externaldb] FROM Table1; 2. SELECT COPY newtable [IN externaldb] FROM Table1; 3. SELECT INTO newtable [IN externaldb] FROM Table1; 4. SELECT ALL INTO newtable [IN externaldb] FROM Table1;

Ans: SELECT INTO newtable [IN externaldb] FROM Table1; Explanation : https://www.w3schools.com/sql/sql_select_into.aspâ€‹

# Coding question

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or `NULL`.

Return a deep copy of the list. Given list 1 -> 2 -> 3 with random pointers going from

1 -> 3 2 -> 1 3 -> 1 You should return a deep copy of the list. The returned answer should not contain the same node as the original list, but a copy of them. The pointers in the returned list should not link to any node in the original input list.

## Solution :

`unordered_map<RandomListNode*,RandomListNode*>m;RandomListNode* Solution::copyRandomList(RandomListNode* A) {    if(!A) return NULL;    m[A]=new RandomListNode(A->label);    m[A]->next=copyRandomList(A->next);    m[A]->random=m[A->random];    return m[A];}â€‹`