LTIMindtree
10+ Nestwell Technologies Interview Questions and Answers
Q1. Sum of Squares of First N Natural Numbers Problem Statement
You are tasked with finding the sum of squares of the first N
natural numbers for given test cases.
Input:
The first line contains an integer 'T', the...read more
Calculate the sum of squares of the first N natural numbers for given test cases.
Read the number of test cases 'T'
For each test case, read the value of 'N'
Calculate the sum of squares of the first 'N' natural numbers
Output the result for each test case
Q2. Reverse a String Problem Statement
Given a string STR
containing characters from [a-z], [A-Z], [0-9], and special characters, determine the reverse of the string.
Input:
The input starts with a single integer '...read more
Reverse a given string containing characters from [a-z], [A-Z], [0-9], and special characters.
Iterate through the characters of the string from end to start and append them to a new string to get the reversed string.
Use built-in functions like reverse() or StringBuilder in languages like Python or Java for efficient reversal.
Ensure to handle special characters and numbers while reversing the string.
Consider edge cases like empty string or strings with only one character.
Q3. Valid Parentheses Problem Statement
Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.
Input:
The first line contains an integer...read more
Check if given strings containing parentheses are balanced or not.
Use a stack to keep track of opening parentheses
Iterate through the string and push opening parentheses onto the stack
When a closing parentheses is encountered, pop from the stack and check if it matches the corresponding opening parentheses
If stack is empty at the end and all parentheses are matched, the string is balanced
Q4. Change Start Node Problem Statement
You are provided with a singly linked list and an integer K
. The objective is to make the Kth
node from the end of the linked list the starting node of the linked list.
Input...read more
Given a singly linked list and an integer K, rearrange the list such that the Kth node from the end becomes the starting node.
Traverse the linked list to find the length and the Kth node from the end.
Update the pointers to rearrange the list accordingly.
Handle edge cases like K being equal to 1 or the length of the list.
Q5. Chocolate Distribution Problem
You are given an array/list CHOCOLATES
of size 'N', where each element represents the number of chocolates in a packet. Your task is to distribute these chocolates among 'M' stude...read more
Distribute chocolates among students to minimize the difference between the largest and smallest number of chocolates.
Sort the array of chocolates in ascending order.
Iterate through the array and find the minimum difference between the elements by considering 'M' elements at a time.
Return the minimum difference found as the result.
Q6. Flip The Bits Problem Statement
Given a binary string S
of length N
where initially all characters are '1', perform exactly M
operations, choosing from four specific operations, and determine how many distinct ...read more
Count the number of distinct final strings possible after performing a given number of operations on a binary string.
Iterate through all possible combinations of operations to determine the final string after each operation.
Use bitwise operations to efficiently flip the bits based on the chosen operation.
Keep track of distinct final strings using a set data structure.
Return the size of the set as the number of distinct final strings.
Q7. Next Greater Element Problem Statement
Given a list of integers of size N
, your task is to determine the Next Greater Element (NGE) for every element. The Next Greater Element for an element X
is the first elem...read more
Find the Next Greater Element for each element in a list of integers.
Iterate through the list of integers from right to left.
Use a stack to keep track of elements for which the Next Greater Element is not yet found.
Pop elements from the stack until a greater element is found or the stack is empty.
Assign the Next Greater Element as the top element of the stack or -1 if the stack is empty.
Q8. Alien Dictionary Problem Statement
You are provided with a sorted dictionary (by lexical order) in an alien language. Your task is to determine the character order of the alien language from this dictionary. Th...read more
Given a sorted alien dictionary in an array of strings, determine the character order of the alien language.
Iterate through the dictionary to build a graph of character dependencies based on adjacent words.
Perform a topological sort on the graph to determine the character order.
Return the character array representing the order of characters in the alien language.
Q9. Inplace Rotate Matrix 90 Degrees Anti-Clockwise
You are provided with a square matrix of non-negative integers of size 'N x N'
. The task is to rotate this matrix by 90 degrees in an anti-clockwise direction wit...read more
Rotate a square matrix by 90 degrees anti-clockwise without using extra space.
Iterate through each layer of the matrix from outer to inner layers
Swap elements in groups of 4 to rotate them in place
Handle odd-sized matrices separately by adjusting the loop boundaries
Q10. Tr2-difference between compiler and interpreter, Solve a challange on their own coding platform with proper output
Difference between compiler and interpreter with a coding challenge
Compiler translates the entire code into machine language before execution while interpreter translates line by line during execution
Compiler generates an executable file while interpreter does not
Compiler is faster but debugging is harder while interpreter is slower but debugging is easier
Coding challenge: Write a program to find the sum of two numbers and print the result
Q11. Tr1- difference between switch case and if else, write the code for sorting
Switch case is used for multiple conditions while if else is for binary conditions. Sorting can be done using various algorithms.
Switch case is faster than if else for multiple conditions
If else is more readable for binary conditions
Sorting can be done using bubble sort, insertion sort, quick sort, etc.
Example code for bubble sort: for(i=0;i
arr[j+1]){swap(&arr[j],&arr[j+1]);}}}
Q12. What is static keyword
The static keyword in programming is used to declare variables, methods, or classes that belong to the class itself rather than instances of the class.
Static variables are shared among all instances of a class.
Static methods can be called without creating an instance of the class.
Static classes cannot be instantiated and are used for grouping related methods and variables.
Example: public static int count = 0; // static variable
Q13. Difference between C and Cpp
C is a procedural programming language while C++ is an object-oriented programming language.
C is a subset of C++.
C does not support classes and objects, while C++ does.
C++ supports function overloading and operator overloading, which C does not.
C++ has a more complex syntax compared to C.
C++ has a standard template library (STL) for data structures and algorithms, which C does not have.
Q14. Give Introduction
I am a software developer with 5 years of experience in Java and Python.
Experienced software developer
Proficient in Java and Python
5 years of industry experience
More about working at LTIMindtree
Top HR Questions asked in Nestwell Technologies
Interview Process at Nestwell Technologies
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month