MAQ Software
80+ Interview Questions and Answers
Nth term of Fibonacci series F(n), where F(n) is a function, is calculated using the following formula -
F(n) = F(n-1) + F(n-2), Where, F(1) = F(2) = 1
Provided N you have to find out the ...read more
Nobita wants to impress Shizuka by guessing her lucky number.
Shizuka gave Nobita a sorted list of ‘N’ numbers such that every number occurred twice in the list except Shizuka’s lu...read more
You are given a string consisting only of parentheses and letters. Your task is to remove the minimum number of invalid parentheses and return all possible unique, valid strings thus o...read more
You are given a non-negative integer 'K'. Your task is to find out the Kth row of Pascal’s Triangle.
In Mathematics, Pascal's triangle is a triangular array where each entry of ...read more
You have given two positive integers N and K. Your task is to print a series of numbers i.e subtract K from N until it becomes 0 or negative then add K until it becomes N. You need to do this task w...read more
You have been given an array/list 'ARR' of integers. Your task is to find the second largest element present in the 'ARR'.
Note:
a) Duplicate elements may be present. b) If no...read more
For a given Singly Linked List of integers, sort the list using the 'Merge Sort' algorithm.
Input format :
The first and the only line of input contains the elements of the linked list sepa...read more
You are given a string 'STR' consisting of lowercase English letters. Your task is to return all permutations of the given string in lexicographically increasing order.
String A is lexic...read more
Given an array with N elements, the task is to rotate the array to the left by K steps, where K is non-negative.
Input Format:
The first line contains an integer N representing the size of the array...read more
You are given an integer ‘N’. You have to print the value of Factorial of ‘N’. The Factorial of a number ‘N’ is defined as the product of all numbers from 1 to ‘N’.
For Example:
Consider if ‘N’ = 4, th...read more
You have been given a linked list where each node has a single character. You have also been given a string 'STR'.
You have to remove all the occurrences of string STR from the linked list.
Note:
1...read more
You are given a 2-dimensional array/list having N rows and M columns, which is filled with ones(1) and zeroes(0). 1 signifies land, and 0 signifies water.
A cell is said to be connected to...read more
You have been given two integers ‘X’ and ‘Y’ which are the first two integers of a series and an integer ‘N’. You have to find the Nth number of the series using the Fibo...read more
Given a string ‘STR’ containing lowercase and uppercase letters. You need to sort the string so that the resulting string contains uppercase and lowercase letters at alter...read more
There are 25 horses among which you need to find out the fastest 3 horses. You can conduct race among at most 5 to find out their relative speed. At no point you can find out the actual speed of the horse...read more
You are given an array of integers ARR[] of size N consisting of zeros and ones. You have to select a subset and flip bits of that subset. You have to return the count of maximum one’s that you can obt...read more
Q17. Which data structure inserts and deletes in O(1) time and is it possible to create a data structure with insertion, deletion and search retrieval in O(1) time
Hash table. No, it is not possible to create a data structure with all operations in O(1) time.
Hash table uses a hash function to map keys to indices in an array.
Insertion and deletion can be done in O(1) time on average.
Search retrieval can also be done in O(1) time on average.
However, worst-case scenarios can result in O(n) time complexity.
It is not possible to create a data structure with all operations in O(1) time.
Q18. Find the third largest element from array, give the optimized approach using just half traversal of array.
Optimized approach to find third largest element from array using half traversal.
Sort the array in descending order and return the element at index 2.
Use a max heap to keep track of the top 3 elements while traversing the array.
Use two variables to keep track of the second and third largest elements while traversing the array.
Divide the array into two halves and find the maximum and second maximum in each half, then compare them to find the third largest element.
You have been given an integer array/list(ARR) of size N which contains numbers from 0 to (N - 2). Each number is present at least once. That is, if N = 5, the array/list constitutes values rangin...read more
You are given a string of length N. You need to reverse the string word by word. There can be multiple spaces between two words and there can be leading or trailing spaces but in the ou...read more
Q21. What are indexes , example, Is it possible to have more than one clustered index and more than one non clustered index ?
Indexes are used to improve query performance. Multiple clustered and non-clustered indexes can be created on a table.
Indexes are used to quickly locate data without scanning the entire table.
Clustered index determines the physical order of data in a table.
Non-clustered index is a separate structure that contains a copy of the indexed columns and a pointer to the actual data.
A table can have only one clustered index, but multiple non-clustered indexes.
Indexes should be create...read more
You are Harshad Mehta’s friend. He told you the price of a particular stock for the next ‘N’ days. You can either buy or sell a stock. Also, you can only complete at most 2-transactions. Find ...read more
You are given an integer 'N'. For a given 'N' x 'N' chessboard, find a way to place 'N' queens such that no queen can attack any other queen on the chessboard.
A queen can be killed when it lies in the ...read more
Q24. What are acid properties , how two transactions occur simultaneously while maintaining Acid properties
ACID properties ensure database transactions are reliable. Two transactions can occur simultaneously using locking and isolation.
ACID stands for Atomicity, Consistency, Isolation, and Durability.
Atomicity ensures that a transaction is treated as a single unit of work, either all or none of it is executed.
Consistency ensures that a transaction brings the database from one valid state to another.
Isolation ensures that concurrent transactions do not interfere with each other.
Dur...read more
You have been given an integer array/list(ARR) of size 'N'. It only contains 0s, 1s and 2s. Write a solution to sort this array/list.
Note :
Try to solve the problem in 'Single Scan'. ' Single Scan' r...read more
You are given an array/list 'ARR' consisting of N integers, which contains elements only in the range 0 to N - 1. Some of the elements may be repeated in 'ARR'. Your task is to find all ...read more
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to return the list of all pairs of elements such that each sum of elements of each pair equals 'S'.
Note:
Each pair shou...read more
You are given a string 'S' of length 'N', you need to find the frequency of each of the characters from ‘a’ to ‘z’ in the given string.
Example :
Given 'S' : abcdg Then output will be : 1 1 1 1 0...read more
Q29. Print first character of words in a string 1) using one stack and 2)using an array.
Answering how to print first character of words in a string using one stack and an array.
For using one stack, push each character onto the stack and pop when a space is encountered. Print the popped character.
For using an array, split the string into words and print the first character of each word.
In both cases, handle edge cases like empty string and string with only one word.
You are given a string, ‘S’. You need to reverse the string where characters that are not an alphabet stay in the same place, and the rest reverse their positions.
Eg: “a-bcd” becomes “d-cba...read more
Ninja is given an integer ‘N’. One day Ninja decides to do the sum of all digits and replace the ‘N’ with the sum of digits until it becomes less than 10. Ninja wants to find what will be the value...read more
You are given an array (ARR) of length N, consisting of integers. You have to find the sum of the subarray (including empty subarray) having maximum sum among all subarrays.
A subarray is a ...read more
Employee table
~~~~~~~~~~~~~~~~
empid, deptid, empname, empsalary
Department table
~~~~~~~~~~~~~~~~~
deptid, depname
Output:
depname, total salary (dep wise)
conditions
~~~~~~~~~~~~
such that only consider e...read more
You are given an integer, all you have to do is to find whether this number is a Fibonacci number or not.
Fn is said to be a Fibonacci sequence such that each number in Fn is the sum of its two ...read more
Q35. Given a array and a number , find whether number can be generated using sum of array members if yes output those numbers
Given an array and a number, find if the number can be generated using sum of array members and output those numbers.
Iterate through the array and check if the number can be generated using the sum of array members
Use a hash table to store the difference between the number and each array element
If the difference is found in the hash table, output the corresponding array elements
If no such combination is found, output 'Not possible'
You are given an array of integers ‘ARR’. Sort the array by performing a series of pancake flips. In one pancake flip, we do the following steps:
Choose an integer ‘K’ where 1 <= ‘K’ <= ARR.LENGT...read more
You are given an array 'ARR' of integers. Your task is to modify the array so that all the array elements having zero values get pushed to the left and all the array elements having non-zero v...read more
You are given an array Arr consisting of N integers. You need to find the equilibrium index of the array.
An index is considered as an equilibrium index if the sum of elements of the array to t...read more
You are given an array/list ‘ARR’ consisting of ‘N’ distinct integers arranged in ascending order. You are also given an integer ‘TARGET’. Your task is to count all the distinct pairs in ‘ARR’ such that...read more
You are given the head of a linked list containing integers, You need to find out whether the given linked list is circular or not.
Note :
1. A linked list is said to be circular if it has no n...read more
You are given a N x M matrix of integers, return the spiral path of the matrix
Example Of Spiral Path
Input Format:
The first line contains an integer 'T' which denotes the number of test cases or...read more
Given a singly linked list, you have to detect the loop and remove the loop from the linked list, if present. You have to make changes in the given linked list itself and return the update...read more
Given an array with N elements, the task is to reverse all the array elements and print the reversed array.
Input Format:
The first line contains an integer N representing the size of the array...read more
Q44. Write a code to find the given linked list is Circular or not ? Then find the node where it is getting circularOther random questions like on: new technologies like clouding , knowledge about different language...
read moreGiven a string 'S', you are supposed to return the number of distinct substrings(including empty substring) of the given string. You should implement the program using a trie.
Note :
A ...read more
Q46. Time complexity of various data structure operations
Time complexity of data structure operations
Arrays: O(1) for access, O(n) for search/insert/delete
Linked Lists: O(n) for access/search, O(1) for insert/delete
Stacks/Queues: O(1) for access/insert/delete
Hash Tables: O(1) for access/insert/delete (average case)
Trees: O(log n) for access/search/insert/delete (balanced)
Heaps: O(log n) for access/insert/delete
Graphs: Varies depending on algorithm used
Mr. X is planning to visit Ninja Land. Ninja Land has 'N' cities numbered from 1 to 'N' and 'M' bidirectional roads. Each road connects two of the 'N' cities, and no two cities have multiple ...read more
write-a-query-to-find-the-nth-highest-salary-and-the-employee-name
I was given two examples 1. Maq - zbh, 2. Cat - fbn. Then I was asked to find the second string using the first, using the relationship in the above strings.
Given n number of rows containing data in this "cityname1 cityname2 distance" format and data is redundant. You have to think about a data structure to store them efficiently.
Q51. Difference between span and div tag
Span and div tags are both HTML elements used for grouping content, but they have different purposes.
Span is an inline element used for grouping text or other inline elements.
Div is a block-level element used for grouping larger sections of content.
Span is often used for styling individual words or phrases within a larger block of text.
Div is often used for creating layout structures and separating content into distinct sections.
Span elements do not create a new line, while d...read more
Q52. -----+all+permutation+of+a+string+geeksforgeeks -----/
Generate all permutations of a given string using recursion and backtracking.
Use recursion to generate all possible permutations of the string.
Use backtracking to backtrack and explore all possible combinations.
Store each permutation in an array of strings.
Q53. 2nd TR:- 1. How can we reduce page loading time in a website.
Reducing page loading time can be achieved through various techniques.
Optimizing images and videos
Minimizing HTTP requests
Using a content delivery network (CDN)
Enabling browser caching
Minimizing JavaScript and CSS files
Using lazy loading for images and videos
Reducing server response time
Using gzip compression
Minimizing redirects
Using a faster web hosting service
Q54. Write a code to reverse the sequence of words in a sentence . For eg: Input Array: I_AM_A_BOY Output Array: BOY_A_AM_I , you can’t use extra array . Input array is the only array that can be used
Write SQL query to find second highest salary from a Table.
What is Normalization and 3NF?
Q57. A circle is inscribed in a square( coordinates top left corner (0,0) ). Coordinates of a point on the circle is given . Calculate the area of circle
Difference delete and truncate
what DML languages
Sql vs no sql
Q59. k nodes reversal of linked list
Reversing k nodes in a linked list
Iterate through the linked list in groups of k nodes
Reverse each group of k nodes
Update the pointers accordingly to maintain the reversed order
Q60. what is joins in sql
Joins in SQL are used to combine rows from two or more tables based on a related column between them.
Joins are used to retrieve data from multiple tables based on a related column
Common types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN
Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column
Q61. Write a code to add two numbers without using ‘+’ operator
Q62. program to find nth prime number and then optimise the code
Program to find nth prime number and optimize the code
Use Sieve of Eratosthenes algorithm to generate prime numbers
Implement binary search to find nth prime number
Use memoization to optimize the code
Avoid unnecessary calculations by checking if a number is prime before checking its factors
Q63. Normalization and all its forms
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity.
Normalization is used to eliminate data redundancy by breaking up tables into smaller, related tables.
There are different normal forms such as 1NF, 2NF, 3NF, BCNF, and 4NF, each with specific rules to follow.
Normalization helps in reducing data anomalies and ensures data integrity.
Example: Breaking up a customer table into separate tables for customer details and orde...read more
Q64. SQL:- add a column on a table, find max salary of employee
Use ALTER TABLE to add a new column and then use MAX function to find the highest salary.
Use ALTER TABLE statement to add a new column to the table.
Use MAX function in SQL to find the maximum salary of employees.
Q65. What are cubes. How are they different from Databases
Cubes are multidimensional data structures used for analysis and reporting. They differ from databases in their structure and purpose.
Cubes store data in a multidimensional format, allowing for efficient analysis and reporting.
They are designed to handle large volumes of data and provide fast query performance.
Cubes use dimensions, measures, and hierarchies to organize and analyze data.
Unlike databases, cubes are optimized for analytical processing rather than transactional p...read more
Q66. Current Windows and Android OS info with their differences from the past versions.
Windows and Android OS have evolved with new features and improvements compared to past versions.
Windows 10 introduced a new Start menu and Cortana virtual assistant.
Android 11 focused on improved privacy controls and messaging features.
Both OS have enhanced security measures compared to their past versions.
Q67. find the occurrence of each element in an array
Count the occurrence of each element in an array of strings
Iterate through the array and use a hashmap to store the count of each element
If element already exists in the hashmap, increment its count by 1
Return the hashmap with element counts
Q68. Index in sql theoretical
Indexes in SQL are used to improve the performance of queries by allowing the database to quickly retrieve data.
Indexes are created on columns in a table to speed up data retrieval.
They work similar to an index in a book, allowing the database to quickly find the relevant data.
Primary keys automatically have an index created on them.
Indexes can be unique, meaning that each value in the indexed column must be unique.
Examples: CREATE INDEX idx_name ON table_name(column_name);
Q69. Write a SQL query to move table from one Schema to other
A SQL query to move a table from one schema to another.
Use the ALTER TABLE statement to rename the table and move it to the new schema.
Specify the new schema name in the ALTER TABLE statement.
Ensure that the user executing the query has the necessary privileges to perform the operation.
Q70. Program to Find Length of String with custom function
Program to find length of string using custom function
Create a custom function that takes an array of strings as input
Iterate through each string in the array and calculate its length
Return the lengths of all strings in an array
Q71. reverse the array
Reverse the array of strings
Create a new array and iterate through the original array in reverse order, adding each element to the new array
Use built-in array methods like reverse() or spread operator for a more concise solution
Ensure to handle edge cases like empty array or array with only one element
Q72. Write a code for Expression Evaluation (BODMAS)
Q73. sort a vector according to other other vector ?
Sort a vector based on another vector
Use std::sort with a custom comparator function
The comparator function should compare the indices of the elements in the second vector
The first vector should be sorted based on the order of the indices in the second vector
Q74. What does a Stored Procedure do
A stored procedure is a precompiled set of SQL statements that can be executed on a database server.
Stored procedures are used to encapsulate and execute complex database operations.
They can be used to improve performance by reducing network traffic.
Stored procedures can be parameterized and reused across multiple applications.
They provide a level of security by allowing access to the database only through the procedure.
Examples: Creating a stored procedure to insert data int...read more
Q75. How to perform state management in react
State management in React involves managing and updating the state of components efficiently.
Use React's built-in state management with setState() method
Utilize React Context API for managing global state
Implement Redux for complex state management in larger applications
Q76. Write code for Level Order Traversal for Binary Tree
Level Order Traversal for Binary Tree is a method to visit all nodes level by level starting from the root.
Use a queue data structure to keep track of nodes at each level
Start by pushing the root node into the queue
While the queue is not empty, dequeue a node, visit it, and enqueue its children
Q77. what are the components of DevOps?
DevOps components include culture, automation, measurement, and sharing.
Culture: Encouraging collaboration and communication between development and operations teams.
Automation: Implementing tools for continuous integration, continuous delivery, and infrastructure as code.
Measurement: Monitoring and analyzing performance metrics to improve processes and identify areas for optimization.
Sharing: Facilitating knowledge sharing and feedback loops to foster continuous improvement.
Q78. What is the role of a project manager
A project manager is responsible for planning, executing, and closing projects within a specific timeframe and budget.
Developing project plans and timelines
Assigning tasks to team members
Monitoring progress and adjusting plans as needed
Communicating with stakeholders
Ensuring project goals are met within constraints
Q79. Alternative character replacement in a string
Replace alternative characters in a string with a specified character
Iterate through the string and replace characters at odd indices with the specified character
Use a loop to go through each character and check if its index is odd or even before replacing
Example: Input string 'hello' and replacement character '*', output 'h*l*'
Q80. Difference between left join and right join
Left join includes all records from the left table and matching records from the right table, while right join includes all records from the right table and matching records from the left table.
Left join keeps all records from the left table, even if there are no matches in the right table.
Right join keeps all records from the right table, even if there are no matches in the left table.
Example: If we have a table of employees and a table of departments, a left join will inclu...read more
Q81. Difference between SSMS, SSIS and SSAS
SSMS is a management tool for SQL Server, SSIS is an ETL tool, and SSAS is a BI tool for analyzing data.
SSMS (SQL Server Management Studio) is a graphical management tool for SQL Server.
SSIS (SQL Server Integration Services) is an ETL (Extract, Transform, Load) tool used for data integration and workflow applications.
SSAS (SQL Server Analysis Services) is a BI (Business Intelligence) tool used for analyzing and reporting data.
SSMS is used for managing databases, creating and ...read more
Q82. SUM OF DIGITS OF A NUMBER(DSA)
Calculate the sum of digits of a given number.
Iterate through each digit of the number and add them together.
Use modulo operator to extract each digit.
Repeat until all digits are processed.
Example: For number 123, sum of digits = 1 + 2 + 3 = 6.
Q83. 2. ATM Working Principles.
ATM (Automated Teller Machine) is an electronic banking outlet that allows customers to complete basic transactions without the aid of a branch representative.
ATMs allow customers to withdraw cash, deposit checks, transfer money between accounts, and check account balances.
ATMs communicate with the bank's computer system to verify account information and process transactions.
ATMs use a magnetic stripe or chip on the customer's debit or credit card to identify the account and ...read more
Q84. Normalisation and keys from dbms
Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. Keys are used to uniquely identify records in a table.
Normalization involves breaking down data into smaller, more manageable parts to reduce redundancy.
Keys are used to uniquely identify records in a table. Examples include primary keys, foreign keys, and candidate keys.
Normalization helps in maintaining data integrity and reducing anomalies such as insertion, updat...read more
Q85. Sort 0,1,2 array
Sort an array of strings containing '0', '1', and '2'.
Use counting sort algorithm to count the occurrences of '0', '1', and '2'.
Create a new array with the sorted counts of '0', '1', and '2'.
Join the sorted array back into a single array of strings.
Q86. Sum of two digit code
Q87. Two Sum Of leetcode
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
Use a hashmap to store the difference between the target and current element
Iterate through the array and check if the current element's complement exists in the hashmap
Return the indices of the two numbers if found
Top HR Questions asked in null
Interview Process at null
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month