0% found this document useful (0 votes)
18 views3 pages

JTG Interview Questions

The document contains a series of programming questions related to data structures and algorithms, including tasks on linked lists, binary trees, arrays, and specific conditions to be met. Each question requires the implementation of a function or algorithm to solve a particular problem, such as dividing linked lists, checking tree properties, and finding specific values in arrays. The questions vary in complexity and cover a range of topics including sorting, searching, and tree manipulation.

Uploaded by

2k22.it.2212483
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

JTG Interview Questions

The document contains a series of programming questions related to data structures and algorithms, including tasks on linked lists, binary trees, arrays, and specific conditions to be met. Each question requires the implementation of a function or algorithm to solve a particular problem, such as dividing linked lists, checking tree properties, and finding specific values in arrays. The questions vary in complexity and cover a range of topics including sorting, searching, and tree manipulation.

Uploaded by

2k22.it.2212483
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1 : Write a program to divide a doubly linked list from middle into two

doubly linked lists.


Q2 : Write a function to check if the given tree holds the given property:
Node->val1 = Node->left->val2 + Node->right->val2.
Q3 : Write a program to find if in a given sorted array, any two elements
sum is equal to given value k. Time Complexity : O(N).
Q4 : Given an array sort a array in the pattern like positive negative
positive negative and so on.
Q-5 A string contains only two characters ‘I’ and ‘D’ where ‘I’ represents
the increasing sequence and ‘D’ represents the decreasing sequence.
Find the minimum number without repetition of the numbers such that it
follows the sequence given in the string. The numbers used in the
sequence must be greater than zero. We have to print ‘String not found’ if
the size of the string is zero and if the size of the string is greater than 8
we have to print ‘String length exceeds’.
INPUT: IDIDI
OUTPUT: 132546

Q-6: We are given a binary tree. The task is to transform every left child
node odd by subtracting one and even child node even by adding one to
it. We have to write solutions in linear time complexity and constant
space.

Q-7: We are given an array of sizes ‘N’. The task is to count greater
elements on the left side of each array element.
INPUT: 5
1 2 3 4 5
OUTPUT: -1 1 2 3 4

Q-8: Given a linked list. Update the value of each node by the sum of itself
data and (n – k)th node data.

Q-9: We are given a circular array of size ‘N’. We have to find the
maximum subarray of size non-empty subarray.

Q-10: You are given an array arr[] of N integers including 0. The task is to
find the smallest positive number missing from the array. Link of the
question: https://www.geeksforgeeks.org/problems/smallest-positive-
missing-number-1587115621/1
Q-11: Given a binary tree. Find the size of its largest subtree which is a
Binary Search Tree. Link of the
question: https://www.geeksforgeeks.org/problems/largest-bst/1

Q-12: We have given a BST. In the tree, generally, we have two pointers
i.e left and right but here they also provide another point named as parent
pointer which is pointing to its parent. Consider a node containing left,
right as well as parent pointer. Now they have given an integer ‘K’, the
task to us is to find all the pairs in BST whose sum is K.

Q-13: Given an array [] of distinct integers of size N, the task is to print the
count of greater elements on the left side of each array element. A

Q-14: You are given a binary tree. You had to transform every left child
node odd by subtracting one and the right child node even by adding 1.
You were expected to implement the solution in constant space and linear
time.

Q-15: Given an unsorted Linked List of integers. The task is to sort the
Linked List into a wave-like Line.

Q-16: Given a circular array of size n, find the maximum subarray sum of
the non-empty subarray. A Solution to this question.

Q-17: Given a linked list were supposed to update the value of each node
by the sum of the node itself and the sum of (n-k)th node.

Q-18: Given information about N petrol pumps (say arr[]) that are present
in a circular path. The information consists of the distance of the next
petrol pump from the current one (in arr[i][0]) and the amount of petrol
stored in that petrol pump (in arr[i][1]). Consider a truck with infinite
capacity that consumes 1 unit of petrol to travel 1 unit distance. The task
is to find the index of the first starting point such that the truck can visit all
the petrol pumps and come back to that starting point.

Q-19: Maximum sum of elements in array such that no two elements are
adjacent to each other.

Q-20: Re-arrange the linked list such that first node=firstnode-last node,
second node=second node-2nd last node.
Example:
1. Input : 1 -> 2 -> 3 -> 5 -> 9 -> 6 -> 3 -> 2 -> 0
2. Output: 1-> 0 -> 0 -> -1 -> 9 -> 6 -> 3 -> 2 -> 0
Explanation: (1-0)->(2-2)->(3-3)->(5-6)->9->6->3->2->0
Q-21: Shift all the nodes to the right if there is an empty place in a Binary
tree. Every level should be filled from the rightmost side. See image for
example:

Q-22: Minimum no. of jumps required to reach the other side of the bridge.
The bridge is represented in the form of an array consisting of 1s and 0s.
1 represents a valid step while 0 represents a broken step. We are given
another array which consists of no of steps we can cover in one jump. We
need to find the minimum jumps required to reach another end.
Example:
Bridge=[1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,0,1]
Jumps=[2,3,5,6]
Output: 4

Q-23: Given a BST we need to check if all the root nodes value is the
average of its left and right node. If the condition is false then delete the
root node. Return a BST that follows the above condition.

You might also like