Algorithms
Top 250 Algorithms Interview Questions and Answers 2024
250 questions found
Updated 13 Dec 2024
Q101. Write a pseudo code to find the k'th largest element in a array
Pseudo code to find the k'th largest element in an array
Sort the array in descending order
Return the element at index k-1
Q102. 2. Program ATM Machine To Give Only 500 And 100 And Count There Number
Program an ATM machine to dispense only 500 and 100 notes and count their number.
Create a function to dispense money
Use a loop to count the number of notes
Use if statements to check if the amount is divisible by 500 or 100
Display the total number of notes dispensed
Q103. Optimize the code for job scheduling written in the first round
Optimize job scheduling code
Use priority queue to efficiently schedule jobs
Implement dynamic programming to optimize job sequence
Consider parallel processing to reduce overall time
Use efficient data structures to store job information
Q104. Solve the problems: Write a formula to display A if A is present, display B if B is present else display None.
Write a formula to display A if A is present, display B if B is present else display None.
Use conditional statements to check if A or B is present
If A is present, display A
If B is present, display B
If neither A nor B is present, display None
Q105. Write code for QuickSort
QuickSort is a sorting algorithm that uses divide and conquer approach.
Choose a pivot element from the array
Partition the array into two sub-arrays, one with elements less than the pivot and one with elements greater than the pivot
Recursively apply the above steps to the sub-arrays
Combine the sorted sub-arrays to get the final sorted array
Q106. Write a code for Octal to Decimal Conversion.
Code for Octal to Decimal Conversion
Start from the rightmost digit and move towards the leftmost digit
Multiply each digit with 8 raised to the power of its position
Add all the products obtained in the previous step to get the decimal equivalent
Q107. Zero Matrix<p>You are given a matrix 'MATRIX' of dimension 'N' x 'M'. Your task is to make all the elements of row 'i' and column 'j' equal to 0 if any element in the ith row or jth column of the matrix is 0.</p> <h4 id="note">Note</h4>...
read moreThe task is to modify a given matrix such that if any element in a row or column is 0, then make all elements in that row and column 0.
Iterate through the matrix and keep track of rows and columns that contain 0s
After the first iteration, iterate through the tracked rows and columns and set all elements to 0
Handle the case where the first row or column contains 0 separately
To solve with O(1) space complexity, use the first row and first column of the matrix to track the rows ...read more
Q108. Print left most node of each level by doing BFs
Print the leftmost node of each level using BFS.
Implement BFS algorithm to traverse the tree level by level.
Keep track of the leftmost node of each level.
Print the leftmost node of each level after traversal is complete.
Algorithms Jobs
Q109. write algorithm for swapping variables
Algorithm for swapping variables
Use a temporary variable to store the value of one variable
Assign the value of the second variable to the first variable
Assign the value of the temporary variable to the second variable
Q110. How to use boolean search?
Boolean search is a technique used to combine keywords and operators to produce more accurate and relevant search results.
Use AND to narrow down search results
Use OR to broaden search results
Use NOT to exclude certain keywords
Use parentheses to group keywords and operators
Example: (Java AND Developer) OR (Python AND Engineer)
Example: (Marketing OR Advertising) NOT Sales
Q111. What are the different sorting technique?
Sorting techniques are algorithms used to arrange data in a specific order.
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
Heap Sort
Radix Sort
Q112. find tree node from leet code
Finding a tree node from LeetCode involves traversing a tree data structure to locate a specific node.
Use depth-first search (DFS) or breadth-first search (BFS) to traverse the tree and find the target node.
Implement a recursive function to search for the node in the tree structure.
Consider using a stack or queue data structure to keep track of nodes to visit next.
Check if the current node is the target node, if not, recursively search in the left and right subtrees.
Handle ed...read more
Q113. Write code to print bottom view of Binary Search Tree
Print the bottom view of a Binary Search Tree.
Use a map to store the horizontal distance and the bottom-most node at that distance.
Traverse the tree in level order and update the map with each node's horizontal distance and level.
Print the nodes in the map in ascending order of their horizontal distance.
Q114. find out the subset of an array of continuous positive numbers from a larger array whose sum of of the elements is larger in comparision to other subset. eg: {1,2 5 -7, 2 5} .The two subarrays are {1,2,5} {2,5}...
read moreFind the subset of an array with the largest sum of continuous positive numbers.
Iterate through the array and keep track of the current sum and the maximum sum seen so far.
If the current element is positive, add it to the current sum. If it is negative, reset the current sum to 0.
Also keep track of the start and end indices of the maximum sum subset.
Return the subset using the start and end indices.
Q115. Is fft a transform by it self?
Yes, FFT is a transform by itself.
FFT stands for Fast Fourier Transform
It is a mathematical algorithm used to transform a signal from time domain to frequency domain
FFT is a standalone transform and can be used for various applications such as signal processing, image processing, and data compression
Q116. Convert int into roman number
Convert integer to Roman numeral
Create an array of Roman numerals and their corresponding integer values
Loop through the array in reverse order and subtract the integer value from the input number until it reaches 0
Append the corresponding Roman numeral to the result string for each subtraction
Handle special cases like 4, 9, 40, 90, etc.
Q117. Find a string in a 2D character matrix in any order(horizontal/vertical/diagonal)
Search for a string in a 2D character matrix in any direction
Iterate through each cell of the matrix
For each cell, check all possible directions for the string
If found, return the starting and ending coordinates of the string
Q118. What is asymptotic notation ?
Asymptotic notation is a way to describe the performance of an algorithm by analyzing its behavior as the input size approaches infinity.
Asymptotic notation is used to analyze the efficiency and scalability of algorithms.
It provides a way to compare algorithms based on their growth rates.
Commonly used asymptotic notations include Big O, Big Omega, and Big Theta.
Big O notation represents the upper bound or worst-case scenario of an algorithm's time complexity.
For example, an a...read more
Q119. Write an algorithm to select the number between min and maximum from a number series and that number shouldn't be a multiple of 10
Algorithm to select a non-multiple of 10 from a number series between min and max
Loop through the number series from min to max
Check if the current number is a multiple of 10
If not, select the number and exit the loop
If all numbers are multiples of 10, return an error message
Q120. Divide the array in two Halves and keep each half in ascending order without using new Array?
Divide array in two halves and keep each half in ascending order without using new Array.
Use Array.sort() method to sort the original array
Use Array.slice() method to divide the array into two halves
Use Array.reverse() method to reverse the second half of the array
Q121. What is Fast Fourier transform
Fast Fourier Transform (FFT) is an algorithm used to compute the Discrete Fourier Transform (DFT) of a sequence or signal.
FFT is used to analyze the frequency content of a signal by decomposing it into its constituent frequencies.
It is commonly used in signal processing, image processing, audio analysis, and many other fields.
FFT algorithms are much faster than the naive DFT computation, making it practical for real-time applications.
Examples of applications include audio equ...read more
Q122. If there is an array of numbers give the sum of number of each element in array
To find the sum of numbers in an array, loop through the array and add each element to a running total.
Create a variable to hold the running total
Loop through the array and add each element to the running total
Return the running total
Q123. Count distinct pairs with difference equal to k and further optimize.
Count distinct pairs with difference equal to k and optimize.
Use a hash set to store the elements of the array.
Iterate through the array and check if the current element + k or current element - k exists in the hash set.
Increment the count if a pair is found and add the current element to the hash set.
Return the count of distinct pairs.
Q124. You have been given a in out time log of viewers and you need to find the highest count of viewers at any given point.
To find highest count of viewers at any given point from in-out time log
Create an array of time slots with start and end time
Loop through the log and increment the count for each time slot
Track the maximum count and corresponding time slot
Return the time slot with highest count
Q125. Find duplicate character and count of given string
Find duplicate characters and their count in a given string.
Create an empty dictionary to store character count
Iterate through the string and add characters to the dictionary
If character already exists in the dictionary, increment its count
Return the dictionary with character count
Q126. Print all combinations of balanced parentheses
Print all combinations of balanced parentheses
Use recursion to generate all possible combinations
Keep track of the number of opening and closing parentheses
Add to the result only if the number of opening and closing parentheses are equal
Q127. 3. How you have considered the computational time?
I have considered computational time by optimizing algorithms and using efficient data structures.
I have analyzed the time complexity of algorithms and chosen the most efficient ones.
I have used data structures like hash tables and binary trees to reduce search time.
I have also parallelized certain tasks to reduce overall computational time.
For example, in my research on image processing, I used parallel computing to speed up the process.
Q128. Explain different algorithms that applies in networking domain
Algorithms used in networking include routing, switching, and security protocols.
Routing algorithms determine the best path for data to travel between devices on a network.
Switching algorithms determine how data is forwarded between network devices.
Security algorithms are used to protect data and prevent unauthorized access.
Examples of routing algorithms include OSPF and BGP.
Examples of switching algorithms include Spanning Tree Protocol and VLANs.
Examples of security algorit...read more
Q129. Given a string of paranthesis tell longest valid parantheisis
Use stack to keep track of indices of opening parentheses, update max length when closing parentheses found
Use a stack to keep track of indices of opening parentheses
When a closing parentheses is found, update max length by calculating the difference between current index and top of stack
Handle edge cases like extra closing parentheses or unmatched opening parentheses
Example: Input: "(()()", Output: 4 (for "()()")
Q130. Explain all the projects and algorithms used in that projects(models)
I have worked on various projects including developing recommendation systems, image recognition algorithms, and natural language processing models.
Developed recommendation system using collaborative filtering algorithm
Implemented image recognition algorithm using convolutional neural networks (CNN)
Utilized natural language processing models such as LSTM for text classification tasks
Q131. Check if a graph has a unique Topological sort
A graph has a unique topological sort if and only if it is a directed acyclic graph (DAG).
A topological sort is a linear ordering of the vertices of a graph such that for every directed edge (u, v), vertex u comes before vertex v in the ordering.
To check if a graph has a unique topological sort, we can use depth-first search (DFS) or breadth-first search (BFS) algorithms.
If during the DFS or BFS traversal, we encounter a back edge or a cycle, then the graph does not have a un...read more
Q132. 4. What is annealing?
Annealing is a heat treatment process used to alter the properties of materials, making them more ductile and less brittle.
Annealing involves heating a material to a specific temperature and then cooling it slowly.
The process relieves internal stresses, improves machinability, and enhances electrical conductivity.
Examples of annealing include the heat treatment of steel to reduce hardness and increase toughness, and the annealing of glass to remove internal stresses.
Q133. Difference between time complexity and space complexity. Explain with example in such a way that you are teaching someone who doesn't know anything about it
Time complexity refers to the amount of time taken by an algorithm to run, while space complexity refers to the amount of memory used by an algorithm.
Time complexity is measured by the number of operations an algorithm performs, while space complexity is measured by the amount of memory an algorithm uses.
An algorithm with a time complexity of O(n) will take longer to run as the input size increases, while an algorithm with a space complexity of O(n) will use more memory as th...read more
Q134. Write down the code for LCA of a binary Tree.
Code for finding the Lowest Common Ancestor (LCA) of a binary tree.
Start by checking if the root is null or equal to either of the given nodes. If so, return the root.
Recursively search for the LCA in the left and right subtrees.
If both nodes are found in different subtrees, return the root as the LCA.
If both nodes are found in the same subtree, continue searching in that subtree.
Q135. Find minimum path from one city to other city
To find minimum path from one city to other city
Use Dijkstra's algorithm or A* algorithm to find the shortest path
Create a graph with cities as nodes and distances as edges
Implement the algorithm in code to get the minimum path
Consider factors like traffic, tolls, and road conditions if applicable
Q136. Create a program to create all the possible combination using 0 and 1 for n number of digits, for example for n = 2, [00,01, 10,11]
Create a program to generate all possible combinations of 0 and 1 for n number of digits.
Use a loop to iterate through all possible combinations
Use binary representation to generate the combinations
Store the combinations in an array of strings
Q137. What is a master theorem, big o notation?
Master theorem and big O notation are used to analyze the time complexity of algorithms.
Master theorem is used to solve recurrence relations that arise in the analysis of algorithms.
Big O notation is used to describe the upper bound of the growth rate of an algorithm's time complexity.
Master theorem can be used to solve the time complexity of divide and conquer algorithms like merge sort and quicksort.
Big O notation is commonly used to compare the efficiency of different algo...read more
Q138. Find the output of the given psuedo code and other technical MCQs
Psuedo code output and technical MCQs for Software Engineer Intern position
Provide examples for technical MCQs
Psuedo code output needs to be calculated
Assess candidate's technical knowledge
Q139. write a job scheduler code to backup up database daily at a particular time
Code to schedule daily database backup
Use SQL Server Agent to create a new job
Set the schedule to run daily at the desired time
Add a step to the job to backup the database
Specify the backup location and file name
Test the job to ensure it runs successfully
Q140. Find the sum of the digits in a reverse order
To find the sum of digits in reverse order, reverse the number and then add the digits together.
Reverse the given number
Separate each digit of the reversed number
Add all the digits together to get the sum
Q141. Find the maximum for each and every contiguous subarray of size k from an arr of size n.
Find maximum for each contiguous subarray of size k from an array of size n.
Iterate through the array and keep track of maximum for each subarray of size k
Use a sliding window approach to efficiently calculate maximum for each subarray
Time complexity: O(n)
Example: arr = [10, 5, 2, 7, 1, 9, 4], k = 3, output = [10, 7, 7, 9, 9]
Q142. Find all subsets of a number set such that sum of these numbers is equal to a given number
Find all subsets of a number set with a given sum
Use a recursive approach to generate all possible subsets
For each subset, calculate the sum and check if it matches the given number
Store the subsets that satisfy the condition
Q143. Write an algorithm to find the absolute max subsequence of an array containing both positive and negative numbers in O(n) time ?
Algorithm to find absolute max subsequence of an array with positive and negative numbers in O(n) time.
Initialize max_so_far and max_ending_here as 0
Loop through the array and for each element, add it to max_ending_here
If max_ending_here becomes negative, reset it to 0
If max_ending_here is greater than max_so_far, update max_so_far
Return max_so_far
Q144. What is selection sort.?
Selection sort is a simple sorting algorithm that repeatedly selects the minimum element from an unsorted portion of the array and swaps it with the first unsorted element.
Iterate through the array to find the smallest element and swap it with the first element.
Repeat the process for the remaining unsorted portion of the array.
Time complexity of O(n^2) makes it inefficient for large datasets.
Q145. Find Peak Element and majority element
Peak and majority element finding algorithms
Peak element: binary search for element greater than both neighbors
Majority element: Boyer-Moore voting algorithm
Boyer-Moore: iterate through array, count occurrences of each element, return element with count > n/2
Q146. Convert roman to int number
Convert roman to int number
Create a dictionary of roman numerals and their integer values
Iterate through the roman numeral string and add corresponding integer values
Subtract twice the value of previous numeral if it is smaller than current numeral
Q147. A point and a rectangle is present with the given coordinates. How will you determine whether the point is inside or outside the rectangle?
To determine if a point is inside or outside a rectangle, we check if the point's coordinates fall within the rectangle's boundaries.
Check if the point's x-coordinate is greater than the left edge of the rectangle
Check if the point's x-coordinate is less than the right edge of the rectangle
Check if the point's y-coordinate is greater than the top edge of the rectangle
Check if the point's y-coordinate is less than the bottom edge of the rectangle
If all four conditions are true...read more
Q148. Number of inversions in an array in O(nlogn) time?
Number of inversions in an array in O(nlogn) time.
Use merge sort algorithm to count inversions
Divide the array into two halves and recursively count inversions
Merge the two halves and count split inversions
Time complexity is O(nlogn)
Q149. Write a one line code to find if a given number is a power of 2
Check if a number is a power of 2 in one line of code.
Use bitwise AND operator to check if the number is greater than 0 and has only one bit set to 1.
If the number is a power of 2, it will have only one bit set to 1 in its binary representation.
Example: (n & (n-1)) == 0 will return true if n is a power of 2.
Q150. Modify Dijkstra algorithm to find 3 Shortest path
Modify Dijkstra algorithm to find 3 shortest paths
Implement a modified version of Dijkstra's algorithm that keeps track of the 3 shortest paths
Use a priority queue to store the nodes and their distances from the source node
When a node is visited, update the distances of its neighbors and add them to the priority queue
Keep track of the 3 shortest paths using an array or a list
Terminate the algorithm when the 3 shortest paths have been found or when the priority queue is empty
Q151. “Compress a text string in place”. Having seen the famous string expansion in place problem many times, I promptly said run length encoding (i.e. compress aaaaaabbbbbccc to a6b5c3 for example). He asked me to c...
read moreCode a run length encoding algorithm to compress a text string in place.
Use a loop to iterate through the string and count consecutive characters
Create a new string to store the compressed version of the original string
Add the character and its count to the new string
Compare the length of the new string to the original string to determine if compression was successful
Q152. Given an array of integers, find Pythagorean triplets. i.e. find a,b and c which satisfies a^2 + b^2 = c^2. Integers could be positive or negative
Find Pythagorean triplets in an array of integers.
Loop through the array and pick two numbers at a time.
Calculate the sum of squares of the two numbers.
Check if the sum is a perfect square.
If yes, then it is a Pythagorean triplet.
Repeat until all possible combinations are checked.
Q153. Find 3 nos a,b and c in an array where a+b = c
Find 3 numbers in an array where a+b=c.
Loop through the array and check for all possible combinations of a and b.
Use a hash table to store the values of a and b, and check if c is present in the hash table.
Sort the array and use two pointers to find a and b, and then check if their sum equals c.
Q154. Write Fibonacci sequence
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones.
Start with two initial numbers, 0 and 1
Each subsequent number is the sum of the two preceding numbers
Repeat this process until the desired number of terms is reached
Q155. what is pruning and why it is used
Pruning is a technique used in machine learning to reduce the size of a decision tree by removing unnecessary branches.
Pruning helps prevent overfitting by simplifying the model.
It improves the model's generalization ability by reducing complexity.
Pruning can be done through pre-pruning or post-pruning.
Pre-pruning involves setting a threshold to stop tree growth early.
Post-pruning involves removing branches that do not contribute significantly to accuracy.
Example: Removing a ...read more
Q156. Tell me the logic of reverse the number?
Reverse the number means to get the digits in the opposite order.
Extract the digits of the number using modulo operator
Multiply the reversed number by 10 and add the next digit
Repeat until all digits are processed
Q157. Find the sum of two numbers without using any mathematical operarors.
Use bitwise operations to find the sum of two numbers without using mathematical operators.
Use bitwise XOR to find the sum of two numbers without carrying.
Use bitwise AND and left shift to find the carry.
Repeat the process until there is no carry left.
Q158. TELL ME SOMETHING ABOUT NMST
NMST stands for National Mathematics and Science Talent Examination.
NMST is a competitive exam conducted for students in the field of mathematics and science.
It aims to identify and nurture talented students in these subjects.
The exam is open to students from various educational boards and schools.
NMST provides a platform for students to showcase their skills and knowledge.
Top performers in NMST are often awarded scholarships and recognition.
Q159. Write code to check if string/Integer is palindrome or not. Example: 2R acEC ar 2 (True)
A code to check if a given string or integer is a palindrome or not.
Convert the given input to a string
Remove any non-alphanumeric characters from the string
Reverse the string
Compare the reversed string with the original string
If they are the same, then the input is a palindrome
Q160. Find a equilibrium index in array
Find an index in array where sum of elements on left side is equal to sum of elements on right side.
Loop through array and calculate sum of all elements
Then loop through array again and check if sum of elements on left side is equal to sum of elements on right side
Return the index if found, else return -1
Q161. If u have a million numbers, how will u find the maximum number from them if → the input is given on the fly i.e. the numbers are entered one by one. → numbers are given 1000 at a time
To find the maximum number from a million numbers entered on the fly or 1000 at a time.
Create a variable to store the maximum number and initialize it to the first number entered
Compare each subsequent number entered with the current maximum and update the variable if necessary
If numbers are given 1000 at a time, store the maximum of each batch and compare them at the end to find the overall maximum
Q162. 2. Build a search algorithm for a social media app
Build a search algorithm for a social media app
Identify relevant search criteria such as keywords, hashtags, user profiles, and location
Rank search results based on relevance and popularity
Implement filters to refine search results
Consider user behavior and search history to personalize results
Optimize search speed and efficiency
Q163. Given 8 iron rods of one kg(with one defective rod) find the defective rod with minimum number of weighs
Find the defective iron rod among 8 rods of 1kg with minimum number of weighs.
Divide the rods into 3 groups of 3, 3, and 2 rods each.
Weigh the first two groups against each other.
If they balance, the defective rod is in the third group.
If they don't balance, the defective rod is in the heavier group.
Divide the heavier group into two groups of 1 and 1 or 2 and 2 rods each.
Weigh the two rods against each other.
If they balance, the defective rod is the remaining one.
If they don'...read more
Q164. Given a string INPUT, find the longest repeating substring
Find the longest repeating substring in a given string.
Create an array of all possible substrings of the given string.
Sort the array in lexicographic order.
Find the longest common prefix between adjacent strings.
Return the longest common prefix found.
If no repeating substring is found, return an empty string.
Q165. How will you implement a shuffle function for a playlist of songs
Implementing a shuffle function for a playlist of songs
Create a new empty playlist
Randomly select a song from the original playlist and add it to the new playlist
Remove the selected song from the original playlist
Repeat until all songs have been added to the new playlist
Return the new shuffled playlist
Q166. How will you print all the subsets of a given set?
Printing all subsets of a given set.
Use recursion to generate all possible subsets.
For each element in the set, either include it or exclude it in the subset.
Base case is when the set is empty, print the subset.
Time complexity is O(2^n) where n is the size of the set.
Q167. Write pseudocode for linear search
Pseudocode for linear search algorithm on an array of strings
Initialize a variable to store the search key
Iterate through each element in the array
Compare each element with the search key
Return the index if found, otherwise return -1
Q168. Find the kth smallest value in an unsorted array
Find the kth smallest value in an unsorted array
Sort the array and return the kth element
Use quickselect algorithm to find the kth smallest element in O(n) time
Build a min heap of size k and traverse the array to find the kth smallest element
Q169. Count the number of subarrays in a given array whose sum is divisible by k.
Count subarrays in an array whose sum is divisible by k.
Create a prefix sum array to keep track of the sum of elements up to a certain index.
Use a hash table to store the frequency of remainders when the prefix sum is divided by k.
For each prefix sum, check if there exists a previous prefix sum with the same remainder.
If yes, add the frequency of that remainder to the count of subarrays.
Update the frequency of the current remainder in the hash table.
Return the count of subarr...read more
Q170. Find maximum element in an array in less dhan O(N)
Find maximum element in an array in less than O(N)
Use divide and conquer approach
Compare maximum of left and right subarrays
Recursively find maximum element
Q171. Find mean of the given array
To find the mean of an array, add all the elements and divide by the number of elements.
Add all the elements of the array
Divide the sum by the number of elements
Return the mean value
Q172. how to reverse the link list? find all possible sub sequences in a given array
Reverse a linked list and find all possible subsequences in a given array.
To reverse a linked list, iterate through the list and change the next pointers of each node to the previous node.
To find all possible subsequences in an array, use recursion and generate all possible combinations of elements.
For example, given the array [1, 2, 3], the possible subsequences are [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3].
Q173. Count Number Of Ones<h4 id="ninja-has-an-integer-n-ninja-is-fond-of-digit-1-so-ninja-wants-to-know-the-number-of-1s-in-each-number-from-0-to-n">Ninja has an integer ‘N’. Ninja is fond of digit ‘1’ so Ninja wants to know the number of 1s in each number from 0 to N.</h4> <h4 id="your-task-is-to-help-the-ninja-in-finding-out-the-number-of-ones-from-0-to-n">Your task is to help the Ninja in finding out the number of ones from</h4>...
read moreThe task is to count the number of occurrences of the digit '1' in each number from 0 to N.
Iterate through each number from 0 to N
Convert each number to a string
Count the number of occurrences of the digit '1' in the string representation of each number
Return the total count of '1's
Q174. Maximum sum of two non-overlapping subarrays of a given size<h4 id="you-are-given-an-array-list-arr-of-integers-and-a-positive-integer-k-your-task-is-to-find-two-non-overlapping-subarrays-contiguous-each-of-length-k-such-that-the-total-sum-of-these-subarrays-is-maximum">You are given an array/list ARR of integers and a positive integer ‘K’. Your task is to find two non-overlapping subarrays (contiguous) each of length</h4>...
read moreThe task is to find two non-overlapping subarrays of length K in an array, such that their sum is maximum.
Iterate through the array and calculate the sum of each subarray of length K
Store the maximum sum obtained from the first subarray
Iterate again and calculate the sum of each subarray of length K, excluding the previous subarray
Store the maximum sum obtained from the second subarray
Return the sum of the two maximum sums
Q175. Write a code, find out the unique element from an array?
Code to find unique element from an array
Loop through array and compare each element with rest of the array
If element is not repeated, add it to a new array
Return the new array with unique elements
Q176. how to find 2 nd largest number
To find the 2nd largest number in an array, sort the array in descending order and return the element at index 1.
Sort the array in descending order
Return the element at index 1
Q177. Calculate second max without second loop and sorting
Find the second maximum value in an array without using a second loop or sorting.
Iterate through the array once, keeping track of the maximum and second maximum values.
Initialize the maximum and second maximum variables with the first and second elements of the array.
Compare each element with the maximum and second maximum variables, updating them if necessary.
At the end of the iteration, the second maximum variable will hold the second largest value.
Q178. In given array find the sum a*a+b*b=c*c
Use a nested loop to iterate through the array and check for the sum of squares of two elements equal to the square of a third element.
Iterate through the array using a nested loop to compare all possible combinations of elements.
Calculate the sum of squares of two elements and check if it equals the square of a third element.
Return the elements if a match is found, otherwise continue iterating.
Q179. How to serve problem
To serve a problem in Sales & Marketing, one must understand the customer's needs and provide tailored solutions.
Listen actively to the customer's concerns and requirements
Identify the root cause of the problem
Offer personalized solutions that address the customer's specific pain points
Provide excellent customer service and support throughout the process
Continuously evaluate and improve the offered solutions based on customer feedback
Q180. Explain the program shown? How it works?
The program is a software application that performs a specific task or set of tasks.
The program is written in a specific programming language.
It may have a user interface or operate in the background.
It takes input data, processes it, and produces output.
It may use algorithms, data structures, and external libraries.
Examples: a calculator program, a file compression program, a web browser.
Q181. Reduce the process time and call back to early
To reduce process time and call back early, we need to analyze the current process and identify bottlenecks.
Analyze the current process flow
Identify bottlenecks and areas of improvement
Implement process improvements such as automation or streamlining
Monitor and measure the impact of changes
Continuously review and improve the process
Q182. How you would teach algorithm to students?
I would teach algorithms to students by providing clear explanations, practical examples, and hands-on coding exercises.
Start by explaining the basic concepts of algorithms, such as input, output, and steps.
Provide real-life examples to help students understand the relevance and applications of algorithms.
Break down complex algorithms into smaller, more manageable steps.
Encourage students to actively participate in the learning process through coding exercises and problem-sol...read more
Q183. What is a algorithm
An algorithm is a step-by-step procedure or set of rules for solving a problem or accomplishing a task.
An algorithm is a well-defined computational procedure.
It consists of a sequence of instructions that are executed in a specific order.
Algorithms can be represented using flowcharts, pseudocode, or programming languages.
They are used in various fields, including mathematics, computer science, and finance.
Examples of algorithms include sorting algorithms (e.g., bubble sort, m...read more
Q184. Find best time to buy and sell stock
The best time to buy and sell stock can be found by identifying the lowest valley and highest peak in the stock prices.
Identify the lowest valley and highest peak in the stock prices
Calculate the difference between the two
Repeat the process for different time periods to find the maximum profit
Consider edge cases where there is no profit to be made
Q185. What were the optimisation techniques used
Various optimisation techniques were used, including linear programming, genetic algorithms, and simulated annealing.
Linear programming was used to optimize resource allocation.
Genetic algorithms were employed for complex optimization problems.
Simulated annealing was utilized for finding global optima in large search spaces.
Q186. Explain one algo ,OOPS concept
OOPS concept - Inheritance
Inheritance is a mechanism in OOPS where a new class is derived from an existing class
The new class inherits all the properties and behavior of the existing class
It allows code reusability and helps in creating a hierarchy of classes
Example: A class 'Car' can be inherited by a class 'SUV' which will have all the properties of 'Car' and additional properties specific to 'SUV'
Inheritance can be of different types - single, multiple, multilevel, hierarc...read more
Q187. 2.what is fully developed flow can you explain in depth with math?
Fully developed flow is a state where the velocity profile of a fluid remains constant over time and distance.
Fully developed flow occurs in long pipes where the fluid has enough time to reach a steady state.
In this state, the velocity profile is parabolic and the flow is laminar.
The Reynolds number is used to determine if the flow is fully developed or not.
Mathematically, fully developed flow is described by the Hagen-Poiseuille equation.
The Hagen-Poiseuille equation relates...read more
Q188. Find first minimum and maximum number in an array using streams
Find first minimum and maximum number in an array using streams
Use IntStream to convert array to stream of integers
Use min() and max() methods to find minimum and maximum values
Use findFirst() method to get the first occurrence of minimum and maximum values
Q189. 1.Find the possible permutation of the given string 2. Remove 3 from the given input (Number) and input should be taken from the user 3. Check whether the given string is Anagram without using map DATA structur...
read moreAnswering questions related to string permutations, removing numbers, and checking for anagrams without using map data structure.
To find permutations of a string, use recursion to swap characters at each position.
To remove a specific character (e.g. '3') from a string, iterate through the string and build a new string without the character.
To check for anagrams without using a map data structure, sort both strings and compare character by character.
Q190. What is RPN and how to calculate RPN?
RPN stands for Risk Priority Number and is used to prioritize risks based on severity, occurrence, and detection.
RPN is calculated by multiplying the severity, occurrence, and detection scores of a risk.
The severity, occurrence, and detection scores are typically rated on a scale of 1-10.
The higher the RPN, the higher the priority of the risk.
RPN can be used to prioritize which risks to address first.
Example: A risk with a severity score of 8, occurrence score of 5, and detec...read more
Q191. How many parameters mantain?
As a CCR Operator, I maintain multiple parameters depending on the plant and equipment.
The number of parameters varies depending on the plant and equipment being operated.
Some common parameters include temperature, pressure, flow rate, and chemical levels.
It is important to monitor and adjust these parameters to ensure safe and efficient operation.
Regular maintenance and calibration of equipment is necessary to ensure accurate readings.
Proper documentation of parameter readin...read more
Q192. Rotate an image in your choice of language
To rotate an image in Python, use the Pillow library's rotate() method.
Import the Image module from the Pillow library
Open the image using the open() method
Use the rotate() method to rotate the image by the desired angle
Save the rotated image using the save() method
Q193. FInd the max triplets such that i
Find the max triplets such that i
Sort the array in ascending order
Iterate over the array and keep track of the maximum triplet
Return the maximum triplet
Q194. Print * using loops
Printing * using loops is a basic programming exercise.
Use nested loops to print * in a pattern
Use a for loop to print * in a straight line
Use a while loop to print * until a certain condition is met
Q195. How to find the largest number in the given array?
To find the largest number in an array, loop through the array and compare each element with a variable holding the current largest number.
Initialize a variable with the first element of the array
Loop through the array and compare each element with the variable holding the current largest number
If the current element is larger than the variable, update the variable with the current element
After the loop, the variable will hold the largest number in the array
Q196. Which provides feasible solution for puzzle problem backtracking or branch and bound
Branch and bound provides a feasible solution for puzzle problems compared to backtracking.
Branch and bound is more efficient in finding optimal solutions by pruning branches that cannot lead to a better solution.
Backtracking explores all possible solutions before finding the optimal one, which can be inefficient for large puzzle problems.
For example, in the traveling salesman problem, branch and bound can be used to find the shortest route by systematically exploring and eli...read more
Q197. What's is effective depth?
Effective depth is the distance from the centroid of the tension reinforcement to the extreme compression fiber.
It is a measure of the strength of a reinforced concrete beam or slab.
It is calculated by subtracting the cover from the overall depth of the section.
It is used to determine the amount of reinforcement required for a given load.
For example, if the overall depth of a beam is 500mm and the cover is 50mm, the effective depth would be 450mm.
Q198. write code for Anagram program
An Anagram program compares two strings to see if they are rearrangements of each other.
Create a function that takes in two strings as input
Remove any spaces and convert both strings to lowercase for accurate comparison
Sort the characters in both strings and compare them to check if they are anagrams
Return true if they are anagrams, false otherwise
Q199. What is DFT why do we need it
DFT stands for Design for Testability, it is a set of techniques used to make testing of integrated circuits more efficient and effective.
DFT helps in ensuring that all parts of the circuit can be tested thoroughly
It includes adding test structures like scan chains, built-in self-test (BIST) circuits, and boundary scan cells
DFT also helps in reducing test time and cost by enabling faster test pattern generation and fault coverage analysis
Q200. How to make partition
To make a partition, you need to use a disk management tool or command prompt.
Open Disk Management tool or Command Prompt
Select the disk you want to partition
Right-click on the unallocated space and select 'New Simple Volume'
Follow the wizard to specify the size and format of the partition
Alternatively, use the 'diskpart' command in Command Prompt to create a partition
Top Interview Questions for Related Skills
Interview Questions of Algorithms Related Designations
Interview experiences of popular companies
Reviews
Interviews
Salaries
Users/Month