Tip 1 : Be very clear with your project explanation.
Tip 2 : Try to cover all the explanations of the CS core subjects.
Tip 1: Make it clear with proper knowledge.
Tip 2: Provide accurate information and avoid lying about things you are not sure of.
It was morning time, starting at 9:00 am. It happened via the Google Meet online process, and it was a very smooth onboarding. The interviewer was very friendly.



We have a linked list 1->2->3->4->5->6->7 and so on. You are supposed to swap pairs of a linked list like swap (1,2), (3,4), (5,6), and so on.
1. You may not modify the data in the list’s nodes; only nodes themselves may be changed. Because imagine a case where a node contains many fields, so there will be too much unnecessary swap.
2. If a pair of a node does not exist, then leave the node as it is.
class Node:
# Constructor to initialize the node object
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
# Function to initialize head
def __init__(self):
self.head = None
# Function to pairwise swap elements of a linked list
def pairwiseSwap(self):
temp = self.head
# There are no nodes in linked list
if temp is None:
return
# Traverse further only if there are at least two
# left
while(temp and temp.next):
# If both nodes are same,
# no need to swap data
if(temp.data != temp.next.data):
# Swap data of node with its next node's data
temp.data, temp.next.data = temp.next.data, temp.data
# Move temp by 2 to the next pair
temp = temp.next.next
# Function to insert a new node at the beginning
def push(self, new_data):
new_node = Node(new_data)
new_node.next = self.head
self.head = new_node
# Utility function to print the LinkedList
def printList(self):
temp = self.head
while(temp):
print temp.data,
temp = temp.next
# Driver program
llist = LinkedList()
llist.push(5)
llist.push(4)
llist.push(3)
llist.push(2)
llist.push(1)
print "Linked list before calling pairWiseSwap() "
llist.printList()
llist.pairwiseSwap()
print "\nLinked list after calling pairWiseSwap()"
llist.printList



'ARR' = [3, 4, -1, 1, 5] and 'K' = 3
Output = [4, 4, 5]
Since the maximum element of the first subarray of length three ([3, 4, -1]) is 4, the maximum element of the second subarray of length three ([4, -1, 1]) is also 4 and the maximum element of the last subarray of length three ([-1, 1, 5]) is 5, so you need to return [4, 4, 5].
It was once again the morning session, and the interviewer was very supportive, giving me a hint to think about the approach. Finally, I came up with the solution that he was expecting.



• The left subtree of a node contains only nodes with data less than the node’s data.
• The right subtree of a node contains only nodes with data greater than the node’s data.
• Both the left and right subtrees must also be binary search trees.

For the given BST and target value ‘K’ = 32, the closest element is 30 as the absolute difference between 30 and 32 (|32 - 30|) is the minimum among all other possible node-target pairs.
# Recursive Python program to find key
# closest to k in given Binary Search Tree.
# Utility that allocates a new node with the
# given key and NULL left and right pointers.
class newnode:
# Constructor to create a new node
def __init__(self, data):
self.key = data
self.left = None
self.right = None
# Function to find node with minimum
# absolute difference with given K
# min_diff --> minimum difference till now
# min_diff_key --> node having minimum absolute
# difference with K
def maxDiffUtil(ptr, k, min_diff, min_diff_key):
if ptr == None:
return
# If k itself is present
if ptr.key == k:
min_diff_key[0] = k
return
# update min_diff and min_diff_key by
# checking current node value
if min_diff > abs(ptr.key - k):
min_diff = abs(ptr.key - k)
min_diff_key[0] = ptr.key
# if k is less than ptr->key then move
# in left subtree else in right subtree
if k < ptr.key:
maxDiffUtil(ptr.left, k, min_diff,
min_diff_key)
else:
maxDiffUtil(ptr.right, k, min_diff,
min_diff_key)
# Wrapper over maxDiffUtil()
def maxDiff(root, k):
# Initialize minimum difference
min_diff, min_diff_key = 999999999999, [-1]
# Find value of min_diff_key (Closest
# key in tree with k)
maxDiffUtil(root, k, min_diff, min_diff_key)
return min_diff_key[0]
# Driver Code
if __name__ == '__main__':
root = newnode(9)
root.left = newnode(4)
root.right = newnode(17)
root.left.left = newnode(3)
root.left.right = newnode(6)
root.left.right.left = newnode(5)
root.left.right.right = newnode(7)
root.right.right = newnode(22)
root.right.right.left = newnode(20)
k = 18
print(maxDiff(root, k))



For the given binary tree

The reverse level order traversal will be {7,6,5,4,3,2,1}.
It was conducted in the late evening and happened very smoothly.
What is Kernel and write its main functions? (Learn)
The kernel is basically a computer program usually considered the central component or module of an OS. It is responsible for handling, managing, and controlling all operations of computer systems and hardware. Whenever the system starts, the kernel is loaded first and remains in the main memory. It also acts as an interface between user applications and hardware.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?