Add office photos
Employer?
Claim Account for FREE

Josh Technology Group

3.0
based on 75 Reviews
Filter interviews by

60+ Global Computer Interview Questions and Answers

Updated 5 Feb 2024
Popular Designations

Q1. Validate Binary Tree Nodes Problem

You are provided with 'N' binary tree nodes labeled from 0 to N-1, where node i has two potential children, recorded in the LEFT_CHILD[i] and RIGHT_CHILD[i] arrays. Determine ...read more

Ans.

The task is to determine if the given binary tree nodes form exactly one valid binary tree.

  • Check if there is only one root node (a node with no parent)

  • Check if each node has at most one parent

  • Check if there are no cycles in the tree

  • Check if all nodes are connected and form a single tree

Add your answer

Q2. Balanced Binary Trees Problem Statement

You are provided with an integer 'H'. Your task is to determine and print the maximum number of balanced binary trees possible with height 'H'.

A balanced binary tree is ...read more

Ans.

The maximum number of balanced binary trees possible with a given height is to be counted and printed.

  • A balanced binary tree is one in which the difference between the left and right subtree heights is less than or equal to 1.

  • The number of balanced binary trees can be calculated using dynamic programming.

  • The number of balanced binary trees with height 'H' can be obtained by summing the product of the number of balanced binary trees for each possible left and right subtree hei...read more

Add your answer

Q3. Wave Array Sorting Problem

Your goal is to sort a given unsorted array ARR such that it forms a wave array.

Explanation:

After sorting, the array should satisfy the wave pattern conditions:

  • ARR[0] >= ARR[1]
  • AR...read more
Ans.

The task is to sort an array in a wave form, where each element is greater than or equal to its adjacent elements.

  • Iterate through the array and swap adjacent elements if they do not follow the wave pattern

  • Start from the second element and compare it with the previous element, swap if necessary

  • Continue this process until the end of the array

  • Repeat the process for the remaining elements

  • Return the sorted wave array

Add your answer

Q4. Pair Sum in BST Problem Statement

Given a Binary Search Tree (BST) and a target value K, determine if there exist two unique elements in the BST such that their sum equals K.

Input:

An integer T, the number of ...read more
Ans.

The task is to check if there exist two unique elements in the given BST such that their sum is equal to the given target 'K'.

  • Traverse the BST in-order and store the elements in a sorted array

  • Use two pointers, one at the beginning and one at the end of the array

  • Check if the sum of the elements at the two pointers is equal to the target 'K'

  • If the sum is less than 'K', move the left pointer to the right

  • If the sum is greater than 'K', move the right pointer to the left

  • Repeat the...read more

Add your answer
Discover Global Computer interview dos and don'ts from real experiences

Q5. Maximum Sum BST Problem Statement

You are presented with a Binary Tree 'root', which may not necessarily be a Binary Search Tree (BST). Your objective is to identify the maximum sum of node values in any subtre...read more

Ans.

The task is to find the maximum sum of node values of any subtree that is a Binary Search Tree(BST).

  • Traverse the binary tree in a bottom-up manner

  • For each node, check if it forms a BST and calculate the sum of its subtree

  • Keep track of the maximum sum encountered so far

  • Return the maximum sum

Add your answer

Q6. Check If Linked List Is Palindrome

Given a singly linked list of integers, determine if the linked list is a palindrome.

Explanation:

A linked list is considered a palindrome if it reads the same forwards and b...read more

Ans.

Check if a given singly linked list of integers is a palindrome or not.

  • Create a function to reverse the linked list.

  • Use two pointers to find the middle of the linked list.

  • Compare the first half of the linked list with the reversed second half to determine if it's a palindrome.

Add your answer
Are these interview questions helpful?

Q7. Find Nodes at Distance K in a Binary Tree

Your task is to find all nodes that are exactly a distance K from a given node in an arbitrary binary tree. The distance is defined as the number of edges between nodes...read more

Ans.

The task is to find all nodes in a binary tree that are at a distance K from a given node.

  • Implement a function that takes the binary tree, target node, and distance K as input.

  • Use a depth-first search (DFS) algorithm to traverse the tree and find the nodes at distance K.

  • Keep track of the distance from the current node to the target node while traversing.

  • When the distance equals K, add the current node to the result list.

  • Continue the DFS traversal to explore other nodes in the...read more

Add your answer

Q8. 0/1 Knapsack Problem Statement

A thief is planning to rob a store and can carry a maximum weight of 'W' in his knapsack. The store contains 'N' items where the ith item has a weight of 'wi' and a value of 'vi'....read more

Ans.

Yes, the 0/1 Knapsack problem can be solved using dynamic programming with a space complexity of not more than O(W).

  • Use a 1D array to store the maximum value that can be stolen for each weight capacity from 0 to W.

  • Iterate through each item and update the array based on whether including the item would increase the total value.

  • The final value in the array at index W will be the maximum value that can be stolen.

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. K Largest Elements Problem Statement

You are given an unsorted array containing 'N' integers. Your task is to find the 'K' largest elements from this array and return them in non-decreasing order.

Input:

The fi...read more
Ans.

Yes, the problem can be solved in less than O(N*log(N)) time complexity using the Quick Select algorithm.

  • Implement Quick Select algorithm to find the Kth largest element in O(N) time complexity.

  • Partition the array around a pivot element and recursively search in the left or right partition based on the position of the pivot.

  • Once you find the Kth largest element, return all elements greater than or equal to it in non-decreasing order.

Add your answer

Q10. Huffman Coding Challenge

Given an array ARR of integers containing 'N' elements where each element denotes the frequency of a character in a message composed of 'N' alphabets of an alien language, your task is ...read more

Ans.

Implement a function to generate Huffman codes for characters based on their frequencies in an alien language message.

  • Use a priority queue to build the Huffman tree efficiently.

  • Assign '0' and '1' to left and right branches of the tree respectively to generate unique binary codes.

  • Ensure that each code distinctly identifies its corresponding character and minimizes the total number of bits used for the message.

View 1 answer

Q11. Segregate Odd-Even Problem Statement

In a wedding ceremony at NinjaLand, attendees are blindfolded. People from the bride’s side hold odd numbers, while people from the groom’s side hold even numbers. For the g...read more

Ans.

Rearrange a linked list such that odd numbers appear before even numbers while preserving the order.

  • Create two separate linked lists for odd and even numbers

  • Traverse the original list and append nodes to respective odd/even lists

  • Combine the odd and even lists while maintaining the order

  • Return the rearranged linked list

Add your answer

Q12. Multiply Linked Lists Problem Statement

Your task is to multiply two numbers represented as linked lists and return the resultant multiplied linked list.

Explanation:

The multiplied list should be a linked list...read more

Ans.

Multiply two numbers represented as linked lists and return the resultant multiplied linked list.

  • Create a function that takes two linked lists as input and returns the product as a linked list

  • Traverse both linked lists to extract the numbers, multiply them, and create a new linked list for the product

  • Handle carry over while multiplying digits and adding to the result linked list

View 1 answer

Q13. Longest Alternating Subsequence Problem

Given an array ARR of integers, determine the length of the longest alternating subsequence.

Input:

ARR = {Array elements}

Output:

Length of the longest alternating subse...read more
Add your answer

Q14. Buy and Sell Stock Problem Statement

Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell transa...read more

Add your answer

Q15. Size of Largest BST in a Binary Tree

Given a binary tree with 'N' nodes, determine the size of the largest subtree that is also a Binary Search Tree (BST).

Explanation:

A Binary Search Tree (BST) is defined as ...read more

Ans.

Find the size of the largest BST subtree in a binary tree.

  • Traverse the tree in a bottom-up manner to check if each subtree is a BST.

  • Keep track of the size of the largest BST found so far.

  • Recursively check if the current subtree is a BST and update the size accordingly.

Add your answer

Q16. Last Stone Weight Problem Explanation

Given a collection of stones, each having a positive integer weight, perform the following operation: On each turn, select the two heaviest stones and smash them together. ...read more

Ans.

This question is about finding the weight of the last stone after repeatedly smashing the two heaviest stones together.

  • Sort the array of stone weights in descending order.

  • Repeatedly smash the two heaviest stones until there is at most 1 stone left.

  • If there is 1 stone left, return its weight. Otherwise, return 0.

Add your answer

Q17. Longest Common Subsequence Problem Statement

Given two strings STR1 and STR2, determine the length of their longest common subsequence.

A subsequence is a sequence that can be derived from another sequence by d...read more

Ans.

The problem involves finding the length of the longest common subsequence between two given strings.

  • Use dynamic programming to solve the problem efficiently.

  • Create a 2D array to store the lengths of common subsequences of substrings.

  • Iterate through the strings to fill the array and find the length of the longest common subsequence.

  • Example: For input STR1 = 'abcde' and STR2 = 'ace', the longest common subsequence is 'ace' with a length of 3.

Add your answer

Q18. Add Two Numbers Represented by Linked Lists

Your task is to find the sum list of two numbers represented by linked lists and return the head of the sum list.

Explanation:

The sum list should be a linked list re...read more

Ans.

Add two numbers represented by linked lists and return the head of the sum list.

  • Traverse both linked lists simultaneously while keeping track of carry from previous sum

  • Create a new linked list to store the sum of the two numbers

  • Handle cases where one linked list is longer than the other by padding with zeros

  • Update the sum and carry values accordingly while iterating through the linked lists

Add your answer

Q19. Closest Leaf in a Binary Tree

Ninja is stuck in a maze represented as a binary tree, and he is at a specific node ‘X’. Help Ninja find the shortest path to the nearest leaf node, which is considered an exit poi...read more

Add your answer

Q20. Minimum Jumps Problem Statement

Bob and his wife are in the famous 'Arcade' mall in the city of Berland. This mall has a unique way of moving between shops using trampolines. Each shop is laid out in a straight...read more

Add your answer

Q21. Matrix Chain Multiplication Problem

Given 'N' 2-dimensional matrices and an array ARR of length N + 1, where the first N integers denote the number of rows in each matrix and the last integer represents the num...read more

Ans.

Find the minimum number of multiplication operations required to multiply a series of matrices together.

  • Use dynamic programming to solve this problem efficiently.

  • Create a 2D array to store the minimum number of operations needed to multiply matrices.

  • Iterate through different combinations of matrices to find the optimal solution.

  • Consider the dimensions of the matrices to determine the number of operations required.

  • Calculate the minimum number of operations by considering all p...read more

Add your answer

Q22. Longest Palindromic Substring Problem Statement

You are provided with a string STR of length N. The task is to find the longest palindromic substring within STR. If there are several palindromic substrings of t...read more

Ans.

Given a string, find the longest palindromic substring within it.

  • Iterate through the string and expand around each character to find palindromes

  • Keep track of the longest palindrome found so far

  • Return the longest palindromic substring

Add your answer

Q23. Spiral Matrix Problem Statement

Given a two-dimensional matrix of integers, print the matrix in a spiral order.

Input:

The first line contains an integer 't' indicating the number of test cases. For each test c...read more
Ans.

Print a two-dimensional matrix in spiral order.

  • Iterate through the matrix in a spiral order by keeping track of the boundaries.

  • Print elements in the order: top row, right column, bottom row, left column.

  • Repeat the process for inner submatrices until all elements are printed.

Add your answer

Q24. Ways To Make Coin Change

Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more

Ans.

The task is to find the total number of ways to make change for a specified value using given denominations.

  • Create a dynamic programming table to store the number of ways to make change for each value up to the target value.

  • Iterate through each denomination and update the table accordingly based on the current denomination.

  • The final answer will be the value in the table at the target value.

  • Consider edge cases such as when the target value is 0 or when there are no denominatio...read more

Add your answer

Q25. Maximum Non-Adjacent Subsequence Sum

Given an array of integers, determine the maximum sum of a subsequence without choosing adjacent elements in the original array.

Input:

The first line consists of an integer...read more
Add your answer

Q26. Unique Element In Sorted Array

Nobita wants to impress Shizuka by correctly guessing her lucky number. Shizuka provides a sorted list where every number appears twice, except for her lucky number, which appears...read more

Ans.

Find the unique element in a sorted array where all other elements appear twice.

  • Iterate through the array and XOR all elements to find the unique element.

  • Use a hash set to keep track of elements and find the unique one.

  • Sort the array and check adjacent elements to find the unique one.

Add your answer

Q27. Sum Root to Leaf Numbers

You are given an arbitrary binary tree consisting of N nodes, each associated with an integer value from 1 to 9. Each root-to-leaf path can be considered a number formed by concatenatin...read more

Add your answer

Q28. Rotate Linked List Problem Statement

Given a linked list consisting of 'N' nodes and an integer 'K', your task is to rotate the linked list by 'K' positions in a clockwise direction.

Example:

Input:
Linked List...read more
Ans.

Rotate a linked list by K positions in a clockwise direction.

  • Traverse the linked list to find the length and the last node.

  • Connect the last node to the head to form a circular linked list.

  • Find the new head by moving (length - K) steps from the last node.

  • Break the circular list at the new head to get the rotated linked list.

Add your answer

Q29. Is Height Balanced Binary Tree Problem Statement

Determine if the given binary tree is height-balanced. A tree is considered height-balanced when:

  1. The left subtree is balanced.
  2. The right subtree is balanced.
  3. T...read more
Add your answer

Q30. N Queens Problem

Given an integer N, find all possible placements of N queens on an N x N chessboard such that no two queens threaten each other.

Explanation:

A queen can attack another queen if they are in the...read more

Add your answer

Q31. Rearrange Linked List Problem Statement

Given a singly linked list in the form 'L1' -> 'L2' -> 'L3' -> ... 'Ln', your task is to rearrange the nodes to the form 'L1' -> 'Ln' -> 'L2' -> 'Ln-1', etc. You must not...read more

Ans.

Rearrange the nodes of a singly linked list in a specific order without altering the data of the nodes.

  • Use two pointers to split the linked list into two halves, reverse the second half, and then merge the two halves alternately.

  • Ensure to handle cases where the number of nodes is odd or even separately.

  • Keep track of the head and tail of each half to properly rearrange the nodes.

  • Ensure to update the next pointers of the nodes correctly to rearrange the linked list in the desir...read more

Add your answer

Q32. Rotate Matrix K Times Problem Statement

Given a matrix, rotate its elements clockwise by 90 degrees, K times.

Each rotation by 90 degrees counts as one.

Input:

Line 1: Two integers M and N, denoting the number ...read more
Add your answer

Q33. Reverse Linked List in K-Groups

Given a linked list consisting of 'N' nodes and an integer 'K', reverse the linked list in groups of size K. Specifically, reverse the nodes in each group starting from (1, K), (...read more

Ans.

Reverse a linked list in groups of size K

  • Iterate through the linked list in groups of size K

  • Reverse each group of nodes

  • Handle cases where the last group has fewer nodes than K

Add your answer

Q34. Merge Two Binary Trees Problem Statement

You are given the roots of two binary trees, root1 and root2. Merge these two trees into a new binary tree. If two nodes overlap, sum the node values as the new node val...read more

Ans.

Merge two binary trees by summing overlapping nodes and retaining non-null nodes.

  • Traverse both trees simultaneously in preorder fashion

  • If both nodes are not null, sum their values for the new node

  • If one node is null, use the non-null node as the new node

  • Recursively merge the left and right subtrees

Add your answer

Q35. Covid Vaccination Distribution Problem

As the Government ramps up vaccination drives to combat the second wave of Covid-19, you are tasked with helping plan an effective vaccination schedule. Your goal is to ma...read more

Ans.

Maximize vaccines administered on a specific day while following certain rules.

  • Distribute vaccines evenly over the given number of days.

  • Ensure the difference in vaccines administered between consecutive days is at most 1.

  • Maximize the number of vaccines administered on the specified day.

  • Keep track of the total number of vaccines administered to not exceed the maximum limit.

  • Implement a function to calculate the maximum number of vaccines administered on the specified day.

Add your answer

Q36. Remove BST Keys Outside Given Range

Given a Binary Search Tree (BST) and a specified range [min, max], your task is to remove all keys from the BST that fall outside this range. The BST should remain valid afte...read more

Add your answer

Q37. Inorder Successor in a Binary Tree

Given an arbitrary binary tree and a specific node within that tree, determine the inorder successor of this node.

Explanation:

The inorder successor of a node in a binary tre...read more

Ans.

Given a binary tree and a specific node, find its inorder successor in the tree.

  • Perform an inorder traversal of the binary tree to find the successor node.

  • If the given node has a right child, the successor is the leftmost node in the right subtree.

  • If the given node does not have a right child, backtrack to find the ancestor whose left child is the given node.

Add your answer

Q38. Zig-Zag Array Rearrangement

You are provided with an array of distinct elements, and your task is to rearrange the array elements in a zig-zag manner. Specifically, for every odd index i, the element ARR[i] sho...read more

Ans.

Rearrange array elements in a zig-zag manner where every odd index element is greater than its neighbors.

  • Iterate through the array and swap elements at odd indices to satisfy the zig-zag condition.

  • Ensure that the swapped elements are greater than their neighbors.

  • Multiple correct zig-zag rearrangements may exist for a given array.

Add your answer

Q39. Nuts and Bolts Problem

You are given a collection of 'N' nuts and 'N' bolts, each having unique sizes. Your objective is to match each nut with its corresponding bolt based on size, adhering to a one-to-one map...read more

Ans.

Matching nuts and bolts based on size in a one-to-one mapping strategy.

  • Iterate through the nuts and bolts arrays to find matching pairs based on size.

  • Use sorting algorithms like quicksort to efficiently match nuts and bolts.

  • Ensure the implementation modifies the input arrays directly to reflect the proper matched order.

Add your answer

Q40. Divide Chocolates Problem Statement

Ninja bought chocolate consisting of several chunks, and the sweetness of each chunk is represented in an array ARR. He wants to divide the chocolate into K + 1 parts (cuts),...read more

Ans.

The task is to maximize the total sweetness of the part that Ninja will get by dividing chocolates into K + 1 parts.

  • Iterate through the array of sweetness values to find the maximum sweetness value.

  • Use binary search to find the maximum sweetness that Ninja can obtain by making cuts.

  • Consider the constraints while implementing the solution.

  • Handle multiple test cases efficiently.

Add your answer

Q41. Sum Root to Leaf Path Problem

You are given an arbitrary binary tree consisting of N nodes where each node is associated with an integer value from 1 to 9. Each root-to-leaf path in the tree represents a number...read more

Ans.

Calculate the total sum of all possible root-to-leaf paths in a binary tree.

  • Traverse the tree from root to leaf nodes, keeping track of the current path sum.

  • Add the path sum to the total sum when reaching a leaf node.

  • Use recursion to explore all possible paths in the tree.

  • Return the total sum modulo (10^9 + 7) as the final result.

Add your answer

Q42. Dijkstra's Shortest Path Problem Statement

You are given an undirected graph with V vertices (numbered from 0 to V-1) and E edges. Each edge connects two nodes u and v and has an associated weight representing ...read more

Ans.

Dijkstra's algorithm is used to find the shortest path distance from a source node to all vertices in an undirected graph.

  • Implement Dijkstra's algorithm to calculate shortest path distances

  • Use a priority queue to efficiently select the next node to visit

  • Initialize distances to all nodes as infinity, except for the source node as 0

  • Update distances based on the weights of edges and choose the shortest path

  • Handle disconnected nodes by assigning a maximum positive integer value

Add your answer

Q43. Reverse Linked List Problem Statement

Given a singly linked list of integers, return the head of the reversed linked list.

Example:

Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Ans.

Reverse a singly linked list of integers and return the head of the reversed linked list.

  • Iterate through the linked list and reverse the pointers to reverse the list

  • Use three pointers to keep track of current, previous, and next nodes

  • Update the head of the reversed linked list once the reversal is complete

Add your answer

Q44. Flatten Binary Tree to Linked List

Transform a binary tree with integer values into a linked list by ensuring the linked list's nodes follow the pre-order traversal order of the binary tree.

Explanation:

Utiliz...read more

Ans.

Flatten a binary tree into a linked list following pre-order traversal order.

  • Use the binary tree's right pointer as the linked list's 'next' pointer.

  • Set each node's left pointer to NULL.

  • Implement the solution without printing within the function.

  • Follow pre-order traversal to flatten the binary tree into a linked list.

Add your answer

Q45. Equilibrium Indices in a Sequence

You are given an array/list named 'SEQUENCE', which consists of 'N' integers. The task is to identify all equilibrium indices in this sequence.

Explanation:

An equilibrium inde...read more

Ans.

Identify equilibrium indices in a given sequence by finding positions where sum of elements before and after is equal.

  • Iterate through the sequence and calculate prefix sum and suffix sum at each index

  • Compare prefix sum and suffix sum to find equilibrium indices

  • Handle edge cases where no equilibrium index exists

  • Return the indices as a sequence of integers or an empty sequence

Add your answer

Q46. Reverse Linked List in Groups of K

You are provided with a linked list containing 'N' nodes and an integer 'K'. The task is to reverse the linked list in groups of size K, which means reversing the nodes in eac...read more

Ans.

Reverse a linked list in groups of size K.

  • Iterate through the linked list in groups of size K.

  • Reverse each group of nodes.

  • Handle cases where the number of elements in the last group is less than K.

Add your answer

Q47. Nodes at Distance K from a Given Node

Given an arbitrary binary tree, a specified node within the tree, and an integer 'K', find all nodes that are exactly 'K' distance away from the specified node. Return a li...read more

Ans.

Find all nodes at a specified distance K from a given node in a binary tree.

  • Traverse the binary tree to find the target node.

  • Use depth-first search to explore nodes at distance K from the target node.

  • Keep track of the distance from the target node while traversing.

  • Return a list of node values at distance K from the target node.

  • Handle cases where no nodes are found at the specified distance.

Add your answer

Q48. Binary Tree Diameter Problem Statement

Given a binary tree, determine the length of its diameter. The diameter is defined as the longest path between any two end nodes in the tree. The path's length is represen...read more

Ans.

The diameter of a binary tree is the longest path between any two end nodes in the tree.

  • Traverse the tree to find the longest path between two leaf nodes.

  • Use depth-first search (DFS) to calculate the height of each subtree.

  • The diameter of the tree is the maximum of the sum of heights of left and right subtrees + 1.

Add your answer

Q49. Dijkstra's Shortest Path Problem

Given an undirected graph with ‘V’ vertices (labeled 0, 1, ... , V-1) and ‘E’ edges, where each edge has a weight representing the distance between two connected nodes (X, Y).

Y...read more

Ans.

Dijkstra's algorithm is used to find the shortest path from a source node to all other nodes in a graph with weighted edges.

  • Implement Dijkstra's algorithm to find the shortest path distances from the source node to all other nodes.

  • Use a priority queue to efficiently select the next node with the shortest distance.

  • Initialize distances to all nodes as infinity except for the source node which is 0.

  • Update distances to neighboring nodes if a shorter path is found.

  • Repeat the proce...read more

Add your answer

Q50. Spiral Matrix Path Problem Statement

Given a N x M matrix of integers, print the spiral order of the matrix.

Input:

The input starts with an integer 'T' representing the number of test cases. Each test case con...read more

Ans.

The problem involves printing the spiral order of a given matrix of integers.

  • Iterate through the matrix in a spiral order by keeping track of the boundaries.

  • Print the elements in the order: top row, right column, bottom row, left column.

  • Continue this process until all elements are printed in spiral order.

Add your answer

Q51. Replace with Sum of Greater Nodes Problem Statement

Convert a given binary search tree (BST) with 'N' nodes into a Greater Tree. In the Greater Tree, each node's data should be updated to the sum of its origina...read more

Ans.

Convert a binary search tree into a Greater Tree by updating each node's data to the sum of its original data plus the data of all nodes with greater or equal values.

  • Traverse the BST in reverse inorder (right, root, left) to update nodes with the sum of greater nodes.

  • Keep track of the sum of greater nodes encountered so far while traversing.

  • Update each node's data with the sum of greater nodes and continue traversal.

Add your answer

Q52. Binary Tree Level Order Traversal

You are given a binary tree of integers. Your task is to return the level order traversal of the given tree.

Input:

The first line contains an integer 'T', representing the num...read more
Ans.

Return the level order traversal of a binary tree given in level order.

  • Use a queue to perform level order traversal of the binary tree

  • Start by pushing the root node into the queue

  • While the queue is not empty, dequeue a node, print its value, and enqueue its children

Add your answer

Q53. Kth Ancestor in a Binary Tree

You are given an arbitrary binary tree consisting of N nodes numbered from 1 to N, an integer K, and a node TARGET_NODE_VAL from the tree. Your task is to find the Kth ancestor of ...read more

Ans.

Find the Kth ancestor of a given node in a binary tree.

  • Traverse the tree to find the path from the target node to the root node.

  • Store the path in a list and return the Kth element from the end.

  • Handle cases where the Kth ancestor does not exist by returning -1.

Add your answer
Q54. What are higher-order functions in JavaScript?
Ans.

Higher order functions are functions that can take other functions as arguments or return functions as their results.

  • Higher order functions can be used to create more flexible and reusable code.

  • They enable functional programming paradigms.

  • Examples of higher order functions include map, filter, and reduce in JavaScript.

Add your answer
Q55. How would you design and develop a to-do list application using local storage?
Ans.

A todo list application using localstorage.

  • Use HTML, CSS, and JavaScript to create the user interface.

  • Use the localstorage API to store and retrieve todo items.

  • Implement features like adding, editing, and deleting todo items.

  • Display the list of todo items and their status.

  • Allow users to mark todo items as completed or incomplete.

Add your answer
Q56. What is hoisting in JavaScript?
Ans.

Hoisting is a JavaScript behavior where variable and function declarations are moved to the top of their containing scope.

  • Hoisting applies to both variable and function declarations.

  • Variable declarations are hoisted but not their initializations.

  • Function declarations are fully hoisted, including their definitions.

  • Hoisting can lead to unexpected behavior if not understood properly.

Add your answer
Q57. What are promises in JavaScript?
Ans.

Promises in JavaScript are objects that represent the eventual completion or failure of an asynchronous operation.

  • Promises are used to handle asynchronous operations such as fetching data from a server or reading a file.

  • They simplify the process of writing asynchronous code by providing a more structured approach.

  • Promises have three states: pending, fulfilled, or rejected.

  • They can be chained together using methods like .then() and .catch().

  • Promises help avoid callback hell an...read more

Add your answer
Q58. Design a sign-in page using only HTML and CSS.
Ans.

Design a signin page using HTML and CSS only

  • Create a form element with input fields for username and password

  • Style the form using CSS to make it visually appealing

  • Add a submit button for users to sign in

  • Consider adding error messages or validation for user input

  • Use CSS to make the page responsive for different screen sizes

Add your answer
Q59. What is memoization in JavaScript?
Ans.

Memoization is a technique in JavaScript to cache the results of expensive function calls for future use.

  • Memoization improves performance by avoiding redundant calculations

  • It is commonly used in recursive functions or functions with expensive computations

  • The cached results are stored in a data structure like an object or a map

  • Memoization can be implemented manually or using libraries like Lodash or Memoizee

Add your answer
Q60. What is the Temporal Dead Zone in JavaScript?
Ans.

Temporal Dead Zone is a behavior in JavaScript where variables are not accessible before they are declared.

  • Temporal Dead Zone occurs when accessing variables before they are declared

  • Variables in the Temporal Dead Zone cannot be accessed or assigned

  • The Temporal Dead Zone is a result of JavaScript's hoisting behavior

  • Example: accessing a variable before it is declared will throw a ReferenceError

Add your answer
Q61. What are arrow functions in JavaScript?
Ans.

Arrow functions are a concise way to write functions in JavaScript.

  • Arrow functions have a shorter syntax compared to regular functions.

  • They do not have their own 'this' value.

  • They do not have the 'arguments' object.

  • They cannot be used as constructors with the 'new' keyword.

  • They are commonly used in functional programming and with array methods like 'map' and 'filter'.

Add your answer
Q62. What is the virtual DOM in JavaScript?
Ans.

Virtual DOM is a lightweight copy of the actual DOM that allows efficient updates and rendering in JavaScript frameworks.

  • Virtual DOM is a concept used in JavaScript frameworks like React.

  • It is a lightweight copy of the actual DOM tree.

  • Changes made to the virtual DOM are compared with the actual DOM to determine the minimal updates needed.

  • This helps in efficient rendering and improves performance.

  • Virtual DOM allows developers to write code as if the entire page is rendered on ...read more

Add your answer
Q63. What is an IIFE (Immediately Invoked Function Expression) in JavaScript?
Ans.

IIFE stands for Immediately Invoked Function Expression. It is a JavaScript function that is executed as soon as it is defined.

  • IIFE is a way to create a function expression and immediately invoke it.

  • It helps in creating a private scope for variables and functions.

  • It is commonly used to avoid polluting the global namespace.

  • IIFE can be written using different syntaxes like using parentheses, function declaration, or arrow functions.

Add your answer
Q64. What is JSX?
Ans.

JSX is a syntax extension for JavaScript that allows you to write HTML-like code in your JavaScript files.

  • JSX stands for JavaScript XML

  • It is commonly used with React to define the structure and appearance of components

  • JSX elements are transpiled into regular JavaScript function calls

  • It allows you to write HTML-like code with JavaScript expressions embedded within curly braces

  • Example:

    Hello, {name}!

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Global Computer

based on 8 interviews
Interview experience
3.8
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

4.0
 • 362 Interview Questions
3.8
 • 334 Interview Questions
3.6
 • 144 Interview Questions
3.7
 • 142 Interview Questions
3.7
 • 142 Interview Questions
4.0
 • 136 Interview Questions
View all
Top Josh Technology Group Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter