Raja Software Labs
10+ Lyzr Interview Questions and Answers
Q1. sort a binary array using one traversal and no extra space
Sort a binary array using one traversal and no extra space.
Use two pointers, one starting from the beginning and one from the end of the array.
Swap the elements if the left pointer points to 1 and the right pointer points to 0.
Continue traversing until the pointers meet in the middle.
Q2. find minimum angle between hour and minute hand.
Find minimum angle between hour and minute hand.
Calculate the angle made by hour hand with 12 o'clock position and minute hand with 12 o'clock position.
Calculate the difference between the two angles.
If the difference is greater than 180 degrees, subtract it from 360 degrees to get the minimum angle.
Q3. We have given a integer array then find the second maximum difference ?
Find the second maximum difference in an integer array.
Sort the array in descending order
Calculate the difference between adjacent elements
Return the second maximum difference
Q4. We have given a integer find the sum of all digits.
Given an integer, find the sum of all its digits.
Convert the integer to a string and iterate over each character to get the sum.
Use modulo operator to get the last digit and add it to the sum, then divide by 10 to remove the last digit.
Recursively call the function with the integer divided by 10 and add the remainder to the sum.
Q5. 0, 1 array sort (keep complexity low)
Sort an array of 0s and 1s with low complexity.
Use two pointers, one at the beginning and one at the end of the array.
Swap 0s from the beginning with 1s from the end until the pointers meet.
Time complexity: O(n), space complexity: O(1).
Q6. Parenthesis balancing Reversing the string Finding the angle between hour and minute hand of clock
Three technical questions related to string manipulation and clock calculations.
For parenthesis balancing, use a stack data structure to keep track of opening and closing brackets.
To reverse a string, use two pointers starting from the beginning and end of the string and swap characters until they meet in the middle.
To find the angle between hour and minute hand of clock, use the formula (30H - 11/2M) degrees, where H is the hour and M is the minute.
Q7. maximum span of 1 in a 0,1 array
Find the maximum span of 1 in a 0,1 array.
Iterate through the array and keep track of the first and last occurrence of 1.
Calculate the difference between the last and first occurrence of 1.
Repeat the process for all 1's in the array and return the maximum difference.
Q8. Find first non repeated character in string?
Find the first non-repeated character in a string.
Iterate through the string and count the frequency of each character.
Return the first character with a count of 1.
Q9. First non repeating Character
Find the first non-repeating character in a string.
Create a hash table to store the frequency of each character in the string.
Iterate through the string and update the frequency in the hash table.
Iterate through the string again and return the first character with a frequency of 1.
Q10. Prime no Add all digits in a number
The question asks to check if a number is prime and add all its digits.
To check if a number is prime, we can use a loop to divide it by all numbers from 2 to its square root.
If the number is divisible by any of these numbers, it is not prime.
To add all digits in a number, we can use a loop to extract each digit and add it to a running total.
Q11. 2nd smallest number
Find the 2nd smallest number in an array of integers.
Sort the array in ascending order
Return the second element in the sorted array
More about working at Raja Software Labs
Interview Process at Lyzr
Top Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month