Add office photos
Engaged Employer

Oracle

3.7
based on 5.2k Reviews
Video summary
Filter interviews by

NTPC Interview Questions and Answers

Updated 9 Mar 2024
Popular Designations

Q1. Find All Pairs Adding Up to Target

Given an array of integers ARR of length N and an integer Target, your task is to return all pairs of elements such that they add up to the Target.

Input:

The first line conta...read more
Ans.

Find all pairs of elements in an array that add up to a given target.

  • Iterate through the array and store each element in a hashmap along with its index.

  • For each element, check if the target minus the element exists in the hashmap.

  • If found, print the pair of elements. If not found, print (-1, -1).

Add your answer

Q2. Bursting Balloons Problem

Given an array ARR of size N, where each element represents the height of a balloon. The task is to destroy all balloons by shooting arrows from left to right. When an arrow hits a bal...read more

Ans.

Find the minimum number of arrows needed to burst all balloons by shooting arrows from left to right.

  • Sort the array in ascending order to make it easier to determine the minimum number of arrows needed.

  • Iterate through the sorted array and count the number of times the height decreases.

  • The count of height decreases plus 1 gives the minimum number of arrows needed to burst all balloons.

Add your answer

Q3. Validate BST Problem Statement

Given a binary tree with N nodes, determine whether the tree is a Binary Search Tree (BST). If it is a BST, return true; otherwise, return false.

A binary search tree (BST) is a b...read more

Ans.

Validate if a binary tree is a Binary Search Tree (BST) based on given properties.

  • Check if the left subtree of a node contains only nodes with data less than the node's data.

  • Verify if the right subtree of a node contains only nodes with data greater than the node's data.

  • Ensure that both the left and right subtrees are also binary search trees.

  • Iterate through the tree in level order form to validate the BST properties.

Add your answer

Q4. Construct Tree from Preorder Traversal

Given a list of integers pre[] of size n, representing the preorder traversal of a special binary tree where each node has 0 or 2 children, and a boolean array isLeaf[] in...read more

Ans.

Construct a binary tree from preorder traversal and leaf node information.

  • Create a binary tree using preorder traversal and leaf node information

  • Use recursion to build the tree

  • Handle both leaf and non-leaf nodes appropriately

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

Q5. Root to Leaf Path Problem Statement

Given a binary tree with 'N' nodes numbered from 1 to 'N', your task is to print all the root-to-leaf paths of the binary tree.

Input:

The first line of the input contains a ...read more
Ans.

Given a binary tree, print all root-to-leaf paths in order.

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

  • Use depth-first search (DFS) to explore all possible paths.

  • Return each path as a string of nodes separated by spaces.

  • Handle cases where nodes have NULL values by skipping them in the path.

  • Ensure the order of nodes in each path is maintained.

Add your answer

Q6. Triplets with Given Sum Problem

Given an array or list ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a specified number K.

Explanation:

A triplet i...read more

Ans.

Identify all distinct triplets within an array that sum up to a specified number.

  • Iterate through the array and use nested loops to find all possible triplets.

  • Check if the sum of the triplet equals the specified number.

  • Print the valid triplets or return -1 if no triplet exists.

Add your answer

Q7. Implement few design patterns

Ans.

Implementing design patterns in software development

  • Singleton pattern ensures a class has only one instance and provides a global point of access to it

  • Factory pattern creates objects without specifying the exact class of object that will be created

  • Observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated

Add your answer

More about working at Oracle

#22 Best Mega Company - 2022
#3 Best Internet/Product Company - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at NTPC

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

Top Full Stack Developer Interview Questions from Similar Companies

3.3
 • 26 Interview Questions
3.7
 • 20 Interview Questions
3.6
 • 18 Interview Questions
3.5
 • 17 Interview Questions
4.0
 • 15 Interview Questions
4.8
 • 14 Interview Questions
View all
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