PeopleStrong
20+ Piaggio Interview Questions and Answers
Q1. Aggressive Cows Problem Statement
Given an array representing positions of stalls and an integer ‘K’ representing the number of aggressive cows, determine the largest minimum distance between any two cows when ...read more
The problem requires assigning aggressive cows to stalls in a way that maximizes the minimum distance between any two cows.
Sort the array of stall positions in ascending order.
Use binary search to find the largest minimum distance between cows.
Check if it is possible to assign cows with this minimum distance by iterating through the sorted array.
If it is possible, update the maximum distance and continue binary search for a larger minimum distance.
Return the maximum distance ...read more
Q2. Count Set Bits Problem Statement
Given a positive integer N
, compute the total number of '1's in the binary representation of all numbers from 1 to N. Return this count modulo 1e9+7 because the result can be ve...read more
The task is to count the total number of '1' in the binary representation of all numbers from 1 to N.
Convert each number from 1 to N into its binary representation
Count the number of '1' bits in each binary representation
Sum up the counts of '1' bits for all numbers
Return the sum modulo 1e9+7
Q3. Reverse Words in a String: Problem Statement
You are given a string of length N
. Your task is to reverse the string word by word. The input may contain multiple spaces between words and may have leading or trai...read more
The task is to reverse the words in a given string, removing any leading or trailing spaces and replacing multiple spaces between words with a single space.
Split the string into words using spaces as delimiters
Reverse the order of the words
Join the reversed words with a single space between them
Remove any leading or trailing spaces
Q4. Remove Consecutive Duplicates From String Problem Statement
Given a string STR
consisting of both lower and upper case characters, your task is to remove consecutive duplicate characters from the string and ret...read more
The task is to remove consecutive duplicate characters from a given string and return the new string.
Iterate through the characters of the string
Compare each character with the next character
If they are the same, skip the next character
If they are different, add the current character to the new string
Return the new string
Q5. Maximum Path Sum in a Matrix
Given an N*M matrix filled with integer numbers, determine the maximum sum that can be obtained from a path starting from any cell in the first row to any cell in the last row.
You ...read more
The question asks to find the maximum sum that can be obtained from a path starting from any cell in the first row to any cell in the last row of a given matrix.
Iterate through each cell in the first row and calculate the maximum sum path ending at that cell
For each cell, calculate the maximum sum path ending at that cell by considering the three possible directions
Store the maximum sum path ending at each cell in a separate matrix
The maximum sum path ending at any cell in th...read more
Q6. Permutation In String Problem Statement
Given two strings, str1
and str2
, determine whether str2
contains any permutation of str1
as a substring.
Input:
str1 = “ab”
str2 = “aoba”
Output:
True
Example:
Explanatio...read more
Q7. Shortest Path in an Unweighted Graph
The city of Ninjaland is represented as an unweighted graph with houses and roads. There are 'N' houses numbered 1 to 'N', connected by 'M' bidirectional roads. A road conne...read more
The problem is to find the shortest path between two houses in an unweighted graph.
The graph represents the city of Ninjaland with houses connected by roads.
The input consists of the number of test cases, number of houses and roads, starting and ending house, and the roads between houses.
The output is a vector of nodes representing the shortest path from the starting house to the ending house.
If there are multiple shortest paths, any one of them can be returned.
The constraint...read more
Q8. Reverse Linked List in Groups of K
You are provided with a linked list containing 'N' nodes and an integer 'K'. The task is to reverse the linked list in groups of size K, which means reversing the nodes in eac...read more
The task is to reverse a linked list in groups of size K.
Iterate through the linked list in groups of size K
Reverse each group using a helper function
Connect the reversed groups to form the final reversed linked list
Q9. Minimum Time Problem Statement
In a city with ‘N’ junctions and ‘M’ bi-directional roads, each junction is connected to other junctions with specified travel times. No road connects a junction to itself, and on...read more
Q10. Rat in a Maze Problem Statement
You need to determine all possible paths for a rat starting at position (0, 0) in a square maze to reach its destination at (N-1, N-1). The maze is represented as an N*N matrix w...read more
Q11. Use of primary key & foreign key
Primary keys uniquely identify records in a table, while foreign keys establish relationships between tables.
Primary keys ensure data integrity by enforcing uniqueness and preventing duplicate records.
Foreign keys create relationships between tables, allowing data to be linked and referenced across multiple tables.
Primary keys are typically used as foreign keys in related tables to establish relationships.
Foreign keys can be used to enforce referential integrity, ensuring tha...read more
Q12. What are the key HR processes in an organization?
Key HR processes in an organization include recruitment, onboarding, performance management, training and development, and employee relations.
Recruitment: Attracting, sourcing, and hiring new employees.
Onboarding: Introducing new employees to the organization and their roles.
Performance management: Setting goals, evaluating performance, and providing feedback.
Training and development: Providing opportunities for employees to learn and grow.
Employee relations: Handling conflic...read more
Q13. String is immutable or mutable in java
String is immutable in Java
Immutable means once created, the value cannot be changed
String class in Java is final and cannot be extended
Any operation on a string creates a new string object
Q14. What is multi threading
Multi threading is the ability of a program to perform multiple tasks concurrently.
It allows for efficient use of CPU resources
Threads share the same memory space
Synchronization is required to avoid race conditions
Examples include web servers handling multiple requests simultaneously
Q15. How to use inner joins
Inner joins are used to combine rows from two or more tables based on a related column between them.
Inner joins return only the matching rows from both tables.
The join condition is specified using the ON keyword followed by the column(s) to join on.
Inner joins can be used to retrieve data from multiple tables based on a common column.
Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;
Q16. Break sentence into list of string of words
Break a sentence into a list of strings of words
Use the split() method to break the sentence into an array of strings
Specify the delimiter to split the sentence by spaces
Handle punctuation marks and special characters appropriately
Q17. How to create table
To create a table, use the CREATE TABLE statement in SQL.
Specify the table name after the CREATE TABLE keyword.
List the column names and their data types within parentheses.
Add any constraints or indexes as needed.
Example: CREATE TABLE employees (id INT, name VARCHAR(50), age INT);
Q18. Vlookup working formula
Vlookup is a function in Excel used to search for a value in a table and return a corresponding value.
Syntax: =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
lookup_value: The value to search for in the first column of the table.
table_array: The range of cells that contains the data.
col_index_num: The column number in the table from which to retrieve the value.
range_lookup: Optional. TRUE for approximate match, FALSE for exact match.
Example: =VLOOKUP(A2, B2:...read more
Q19. What is Boolean search
Boolean search is a type of search that allows users to combine keywords with operators such as AND, OR, NOT to produce more relevant results.
Boolean search helps recruiters to narrow down their search results by using specific keywords and operators.
Operators like AND, OR, NOT can be used to refine search queries.
Example: Searching for 'Java AND Developer' will return results that include both keywords.
Example: Searching for 'Java OR Python' will return results that include ...read more
Q20. H lookup formula
HLOOKUP is a function in Excel used to search for a value in the top row of a table and return a value in the same column from a specified row.
HLOOKUP stands for Horizontal Lookup.
It is used to search for a value in the top row of a table and return a value in the same column from a specified row.
Syntax: =HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])
Example: =HLOOKUP(123, A1:D4, 3, FALSE) will search for 123 in the top row of the table A1:D4 and return the...read more
Q21. Use of select command
The SELECT command is used to retrieve data from a database table.
SELECT is a fundamental SQL command used in database management systems.
It allows you to specify the columns and rows you want to retrieve from a table.
You can use various clauses like WHERE, ORDER BY, GROUP BY, etc. to filter and sort the data.
The result of a SELECT query is a result set or a cursor containing the selected data.
Example: SELECT * FROM employees;
Example: SELECT name, age FROM customers WHERE age...read more
Q22. distance bw 2 nodes in binary tree
To find the distance between two nodes in a binary tree, we can find the distance from the root to each node and then calculate the distance between the two nodes.
Calculate the distance from the root to each node using a recursive function
Find the lowest common ancestor of the two nodes
Calculate the distance from each node to the lowest common ancestor and add them together to get the total distance
Q23. Maximum sum of longest subarray
Find the maximum sum of a subarray within an array of integers.
Iterate through the array and keep track of the current sum and maximum sum.
If the current sum becomes negative, reset it to 0.
Return the maximum sum found.
Q24. Find circle in linkedList
Use Floyd's Tortoise and Hare algorithm to find a cycle in a linked list.
Initialize two pointers, slow and fast, at the head of the linked list.
Move slow pointer by one step and fast pointer by two steps until they meet.
If they meet, there is a cycle in the linked list.
Example: 1 -> 2 -> 3 -> 4 -> 2 (cycle at node 2)
Q25. Relocation is comfortable
Relocation can be comfortable with proper planning and support.
Proper planning and research can help make the relocation process smoother
Having a support system in place can ease the transition to a new location
Utilizing relocation services provided by the company can also make the process more comfortable
Q26. Explain normalization in sql?
Normalization in SQL 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.
It helps in reducing data anomalies such as update anomalies, insert anomalies, and delete anomalies.
There are different levels of normalization - 1NF, 2NF, 3NF, BCNF, and 4NF, each with specific rules to follow.
Normalization ensures that each piece of data is ...read more
Q27. valid sudoku of 9*9
A valid sudoku of 9*9 is a grid where each row, column, and 3x3 subgrid contains the numbers 1-9 without repetition.
Each row must contain the numbers 1-9 without repetition
Each column must contain the numbers 1-9 without repetition
Each 3x3 subgrid must contain the numbers 1-9 without repetition
Q28. Reversing a string
Reversing a string involves flipping the order of characters in a given string.
Create an empty string to store the reversed string
Iterate through the original string from the end to the beginning
Append each character to the empty string
Return the reversed string
Top HR Questions asked in Piaggio
Interview Process at Piaggio
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month