GenC Next

20+ GenC Next Interview Questions and Answers

Updated 24 Mar 2023

Q1. Pair Sum Problem Statement

You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.

Note:

Each pa...read more

Ans.

Find pairs of elements in an array that sum up to a given value, sorted in a specific order.

  • Iterate through the array and for each element, check if the complement (S - current element) exists in a hash set.

  • Keep track of pairs in a hash set to avoid duplicates.

  • Sort the pairs based on the criteria mentioned in the problem statement.

  • Return the sorted list of pairs.

Q2. Minimum Steps for a Knight to Reach Target

Given a square chessboard of size 'N x N', determine the minimum number of moves a Knight requires to reach a specified target position from its initial position.

Expl...read more

Ans.

Calculate minimum steps for a Knight to reach target position on a chessboard.

  • Use BFS algorithm to find shortest path from Knight's starting position to target position.

  • Consider all possible moves of the Knight on the chessboard.

  • Keep track of visited positions to avoid revisiting them.

  • Return the minimum number of moves required for the Knight to reach the target position.

GenC Next Interview Questions and Answers for Freshers

illustration image

Q3. 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.

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

  • Consider edge cases like when the target value is 0 or when there are no denominations that can make the change.

  • Example: ...read more

Frequently asked in,

Q4. Sort Array Problem Statement

Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.

Input:

Each input starts wi...read more
Ans.

Sort an array of positive integers (0, 1, 2) in non-decreasing order.

  • Iterate through the array and count the occurrences of 0, 1, and 2.

  • Update the array with the counts of each element in non-decreasing order.

  • Print the sorted array for each test case.

Are these interview questions helpful?

Q5. Quick Sort Problem Statement

You are given an array of integers. Your task is to sort this array in ascending order using the Quick Sort algorithm.

Quick Sort utilizes a divide and conquer approach where a pivo...read more

Ans.

Quick Sort is a divide and conquer algorithm that sorts an array in ascending order by choosing a pivot and partitioning the array into smaller subarrays.

  • Choose a pivot element from the array.

  • Partition the array into two subarrays - one with elements smaller than the pivot and one with elements larger than the pivot.

  • Recursively apply the same process on the subarrays until the entire array is sorted.

  • Complexity can be optimized to NlogN in the worst-case scenario.

Q6. Rat In a Maze Problem Statement

Given a N * N maze with a rat placed at position MAZE[0][0], find and print all possible paths for the rat to reach its destination at MAZE[N-1][N-1]. The rat is allowed to move ...read more

Ans.

The problem statement involves finding all possible paths for a rat to reach its destination in a maze.

  • Create a recursive function to explore all possible paths from the starting position to the destination.

  • Use backtracking to backtrack and explore other paths if the current path leads to a dead end.

  • Mark the cells visited by the rat with 1 and unvisited cells with 0 in the output path.

  • Ensure the rat can only move through cells marked as 1 in the maze.

  • Consider constraints such...read more

Frequently asked in,

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. Maximum Product Subarray Problem Statement

Given an array arr of integers, your task is to identify the contiguous subarray within the array which has the highest product of its elements. Return this maximum pr...read more

Ans.

The task is to find the contiguous subarray within an array with the highest product of its elements.

  • Iterate through the array and keep track of the maximum and minimum product ending at each index.

  • Update the maximum product by considering the current element, maximum product ending at the previous index multiplied by the current element, and minimum product ending at the previous index multiplied by the current element.

  • Return the maximum product found during the iteration.

  • Ex...read more

Q8. Remove Duplicates from Sorted Array Problem Statement

You are given a sorted integer array ARR of size N. Your task is to remove the duplicates in such a way that each element appears only once. The output shou...read more

Ans.

The task is to remove duplicates from a sorted integer array in-place and return the length of the array after removal.

  • Use two pointers approach to iterate through the array and remove duplicates in-place.

  • Update the array by shifting non-duplicate elements to the front.

  • Return the count of unique elements as the length of the array after removal.

Q9. When two dice are thrown together, what is the probability that the sum of the numbers appearing on them is a prime number?
Ans.

The probability of getting a prime sum when two dice are thrown together.

  • There are 36 possible outcomes when two dice are thrown together (6 sides on each die).

  • List out all the possible outcomes and find the ones where the sum is a prime number.

  • Calculate the probability by dividing the number of favorable outcomes by the total possible outcomes.

Q10. What are the bounding methods in React? Difference between Class Component and Functional Component in ReactJS?

Ans.

Bounding methods in React are used to limit the scope of a component's updates.

  • Bounding methods include shouldComponentUpdate, getSnapshotBeforeUpdate, and componentDidUpdate.

  • shouldComponentUpdate allows a component to decide if it should update based on changes in props or state.

  • getSnapshotBeforeUpdate allows a component to capture information before a change is made to the DOM.

  • componentDidUpdate is called after a component updates and can be used to perform additional actio...read more

Q11. Write a program to perform Binary search on an array of N numbers.

Ans.

Program to perform Binary search on an array of N numbers.

  • Sort the array in ascending order

  • Set low and high variables to the first and last index of the array respectively

  • Calculate the mid index as (low+high)/2

  • If the element at mid index is equal to the search element, return mid

  • If the element at mid index is less than the search element, set low to mid+1

  • If the element at mid index is greater than the search element, set high to mid-1

  • Repeat until low is greater than high or e...read more

Q12. What are the different regularization techniques?

Ans.

Regularization techniques are used to prevent overfitting in machine learning models.

  • L1 regularization (Lasso)

  • L2 regularization (Ridge)

  • Elastic Net regularization

  • Dropout regularization

  • Early stopping

  • Data augmentation

  • Batch normalization

Q13. What is virtual DOM and why ReactJS uses it?

Ans.

Virtual DOM is a lightweight copy of the actual DOM used for efficient updates.

  • Virtual DOM is a concept where a lightweight copy of the actual DOM is created.

  • ReactJS uses it to efficiently update the UI without re-rendering the entire page.

  • Virtual DOM compares the previous and current states and updates only the necessary changes.

  • This results in faster rendering and better performance.

  • Example: When a user types in a search bar, only the search results are updated, not the ent...read more

Q14. Explain all the stages of creating a machine learning model on a given dataset

Ans.

Creating a machine learning model involves data preparation, model selection, training, evaluation, and deployment.

  • Data preparation involves cleaning, transforming, and splitting the data into training and testing sets.

  • Model selection involves choosing the appropriate algorithm and hyperparameters for the problem.

  • Training the model involves feeding the training data to the algorithm and adjusting the parameters to minimize the error.

  • Evaluation involves testing the model on th...read more

Q15. Write a program to perform Merge sort on an array of N numbers.

Ans.

Program to perform Merge sort on an array of N numbers.

  • Divide the array into two halves recursively

  • Sort the two halves using merge sort

  • Merge the two sorted halves

  • Repeat until the entire array is sorted

  • Time complexity: O(nlogn)

Q16. What is the formula for gradient descent?

Ans.

Gradient descent is an optimization algorithm used to minimize the cost function of a machine learning model.

  • Start with an initial guess for the model parameters

  • Calculate the gradient of the cost function with respect to each parameter

  • Update the parameters in the opposite direction of the gradient

  • Repeat until convergence or a maximum number of iterations is reached

Q17. What is your favourite technology?

Ans.

My favorite technology is artificial intelligence.

  • AI has the potential to revolutionize various industries

  • It can automate repetitive tasks and improve efficiency

  • AI can also help in making better decisions by analyzing large amounts of data

  • Examples include chatbots, image recognition, and predictive analytics

Q18. What is poison distribution?

Ans.

Poison distribution refers to the spread of toxic substances through various means.

  • Poison distribution can occur through intentional or accidental means.

  • Examples include the distribution of poison through food or water, or the release of toxic chemicals into the environment.

  • Poison distribution can have serious health consequences and may require immediate medical attention.

  • Prevention measures such as proper storage and disposal of toxic substances can help prevent poison dist...read more

Q19. What is PCA?

Ans.

PCA stands for Principal Component Analysis. It is a statistical technique used for dimensionality reduction.

  • PCA is used to identify patterns in data and reduce the number of variables in a dataset.

  • It works by transforming the original variables into a new set of variables called principal components.

  • These principal components are ordered by the amount of variance they explain in the data.

  • PCA is commonly used in fields such as finance, biology, and image processing.

  • Example: P...read more

Q20. Explain any clustering algorithm.

Ans.

Clustering algorithm groups similar data points together based on their characteristics.

  • Clustering is an unsupervised learning technique.

  • It can be used for customer segmentation, image segmentation, etc.

  • K-means, hierarchical clustering, and DBSCAN are popular clustering algorithms.

  • The choice of algorithm depends on the data and the problem at hand.

Q21. Find if the 5th bit of a number is set or cleared

Ans.

To find if the 5th bit of a number is set or cleared.

  • Use bitwise AND operator with 0b10000 to check if the 5th bit is set or cleared.

  • If the result is 0, the 5th bit is cleared. If it is greater than 0, the 5th bit is set.

  • Example: num & 0b10000 == 0 means 5th bit is cleared in num.

Q22. Write a program to reverse your name.

Ans.

A program to reverse a given name.

  • Create a variable to store the name

  • Loop through the name from the last character to the first

  • Add each character to a new variable

  • Print the reversed name

Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions for GenC Next Related Skills

Interview experiences of popular companies

3.8
 • 5.6k Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

GenC Next Interview Questions
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
65 L+

Reviews

4 L+

Interviews

4 Cr+

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