
PeopleStrong


10+ PeopleStrong Interview Questions and Answers for Freshers
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. 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
Q7. 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
Q8. 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
The problem involves finding the minimum time to travel from a source junction to a destination junction in a city with specified travel times and green light periods.
Input consists of the number of test cases, number of junctions and roads, green light periods, road connections with travel times, and source/destination junctions.
Output should be the minimum time needed from source to destination, or -1 if destination is unreachable.
Constraints include limits on test cases, j...read more
Q9. 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
Check if a string contains any permutation of another string as a substring.
Iterate through str2 with a sliding window of length str1, check if any permutation of str1 is present.
Use a hashmap to store the frequency of characters in str1 and str2 for comparison.
If the frequencies of characters in the sliding window match the frequencies of characters in str1, return True.
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
Find all possible paths for a rat in a maze from start to finish, moving in 'U', 'D', 'L', 'R' directions.
Use backtracking to explore all possible paths in the maze.
Keep track of visited cells to avoid loops.
Recursively try moving in all directions and backtrack when reaching dead ends.
Return the valid paths in alphabetical order as an array of strings.
Q11. 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
Q12. 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
Q13. 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
Q14. 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.
Q15. 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 PeopleStrong for Freshers
Interview Process at PeopleStrong for Freshers

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

