Microsoft Corporation
60+ Ray International Llc Oman Interview Questions and Answers
Q1. Nth Term of Geometric Progression (GP) Series
Determine the Nth term of a geometric progression (GP) series given the first term, common ratio, and the term number.
Explanation:
The general form of a GP series ...read more
Q2. Dice Throw Problem Statement
You are provided with D
dice, each having F
faces numbered 1 to F
, inclusive. Your task is to determine the number of possible ways to roll the dice such that the sum of the face-up...read more
Q3. Mean, Median, Mode Calculation
You are given an array 'ARR' consisting of 'N' integers. Your task is to calculate the three statistical measures for the given array:
- Mean - Implement the function
mean()
to cal...read more
Q4. Distinct Subsequences of a String
Given a string S
of length N
that may contain duplicate alphabets, your task is to compute the count of distinct subsequences of this string.
Example:
Input:
S = "deed"
Output:...read more
Q5. Median of Two Sorted Arrays
Given two sorted arrays A
and B
of sizes N
and M
, find the median of the merged array formed by combining arrays A
and B
. If the total number of elements, N + M
, is even, the median ...read more
Q6. Arithmetic Expression Evaluation Problem Statement
You are provided with a string expression
consisting of characters '+', '-', '*', '/', '(', ')' and digits '0' to '9', representing an arithmetic expression in...read more
Q7. Identical Trees Problem Statement
Given two binary trees with 'N' and 'M' nodes respectively, determine if the two trees are identical. Return true
if they are identical, otherwise return false
.
Input:
The firs...read more
Q8. Minimum Subarray with Required Sum Problem Statement
Given an array of positive integers ARR
and an integer X
, determine the minimum length subarray where the sum of its elements is strictly greater than X
.
Not...read more
Q9. Longest Palindromic Subsequence Problem Statement
Ninja receives a PS5 from Santa, locked in a safe with a password. The password is the length of the longest palindromic subsequence in the given string SECRETC...read more
Q10. Delete Kth Node from End of Linked List
This problem requires you to delete the Kth node from the end of a given singly linked list with N nodes containing integer data.
You are asked to efficiently remove this...read more
Q11. Reverse a Linked List Problem Statement
Given a singly linked list of integers, your task is to return the head of the reversed linked list.
Example:
Input:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL.
Out...read more
Q12. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
Q13. Pair Sum Problem Statement
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.
Note:
Each pa...read more
Q14. Maximum Product Subarray Problem Statement
Given an array of integers, determine the contiguous subarray that produces the maximum product of its elements.
Explanation:
A subarray can be derived from the origin...read more
Q15. Swap Numbers Without Temporary Variable
Your task is to interchange the values of two numbers given as variables 'X' and 'Y' without using a temporary variable or any additional variable.
Explanation:
You need ...read more
Q16. Connect Nodes at the Same Level
Given a binary tree where each node has at most two children, your task is to connect all adjacent nodes at the same level. You should populate each node's 'next' pointer to its ...read more
Q17. Minimum Number of Platforms Problem
Your task is to determine the minimum number of platforms required at a railway station so that no train has to wait.
Explanation:
Given two arrays:
AT
- representing the ar...read more
Q18. Maximum Subarray Sum Problem Statement
Given an array arr
of length N
consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.
Explanation:
A sub...read more
Q19. Longest Common Prefix After Rotation
You are given two strings 'A' and 'B'. While string 'A' is constant, you may apply any number of left shift operations to string 'B'.
Explanation:
Your task is to calculate ...read more
Q20. Minimum Steps for a Knight to Reach Target
Given a square chessboard of size 'N x N', determine the minimum number of moves a Knight requires to reach a specified target position from its initial position.
Expl...read more
Q21. Longest Palindromic Substring Problem Statement
You are provided with a string STR
of length N
. The goal is to identify the longest palindromic substring within this string. In cases where multiple palindromic ...read more
Q22. Rotate Matrix by 90 Degrees Problem Statement
Given a square matrix 'MATRIX' of non-negative integers, rotate the matrix by 90 degrees in an anti-clockwise direction using only constant extra space.
Input:
The ...read more
Q23. Minimum Operations Problem Statement
You are given an array 'ARR'
of size 'N'
consisting of positive integers. Your task is to determine the minimum number of operations required to make all elements in the arr...read more
Q24. N Queens Problem
Given an integer N
, find all possible placements of N
queens on an N x N
chessboard such that no two queens threaten each other.
Explanation:
A queen can attack another queen if they are in the...read more
Q25. Travelling Salesman Problem
Given a list of cities numbered from 0 to N-1 and a matrix DISTANCE
consisting of 'N' rows and 'N' columns, representing the distances between each pair of cities, find the shortest ...read more
Q26. Sort Stack Problem Statement
You are given a stack S
. Your task is to sort the stack recursively in descending order.
Constraints:
- Looping through the stack is not allowed.
- Return the stack sorted in descendin...read more
Q27. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
Q28. Validate BST Problem Statement
Given a binary tree with N
nodes, determine whether the tree is a Binary Search Tree (BST). If it is a BST, return true
; otherwise, return false
.
A binary search tree (BST) is a b...read more
Q29. Problem Statement: Sibling Nodes
You are provided with a Binary Tree consisting of 'N' nodes, where each node holds an integer value. Your objective is to identify and list all nodes that do not possess a sibli...read more
Q30. Total Number of BSTs Using Array Elements as Root Node
You are given a sequence array 'ARR' of 'N' integers. For each ARR[i] where 0 <= 'i' < 'N', your task is to find the number of Binary Search Trees (BST) po...read more
Q31. Find All Triplets with Zero Sum
Given an array Arr
consisting of N
integers, find all distinct triplets in the array that sum up to zero.
Explanation:
An array is said to have a triplet {Arr[i], Arr[j], Arr[k]}...read more
Q32. Problem: Sort an Array of 0s, 1s, and 2s
Given an array/list ARR
consisting of integers where each element is either 0, 1, or 2, your task is to sort this array in increasing order.
Input:
The input starts with...read more
Q33. Spiral Matrix Problem Statement
You are given a N x M
matrix of integers. Your task is to return the spiral path of the matrix elements.
Input
The first line contains an integer 'T' which denotes the number of ...read more
Q34. Smallest Window Problem Statement
Given two strings S
and X
containing random characters, the task is to find the smallest substring in S
which contains all the characters present in X
.
Input:
The first line co...read more
Q35. Total Area of Overlapping Rectangles Problem Statement
Determine the total area covered by two given rectangles on a 2-D coordinate plane, which may have an overlapping area.
Input:
The first line contains an i...read more
Q36. Find the Largest Common Ancestor Problem
Given a binary search tree and two distinct nodes within it, the task is to determine their largest common ancestor. This ancestor is defined as the common ancestor with...read more
Q37. LCA of Binary Tree Problem Statement
You are given a binary tree of distinct integers, along with two nodes, ‘X’ and ‘Y’. Your task is to determine the Lowest Common Ancestor (LCA) of ‘X’ and ‘Y’.
The LCA of tw...read more
Q38. Mirror String Problem Statement
Given a string S
containing only uppercase English characters, determine if S
is identical to its reflection in the mirror.
Example:
Input:
S = "AMAMA"
Output:
YES
Explanation:
T...read more
Q39. Cycle Detection in a Singly Linked List
Determine if a given singly linked list of integers forms a cycle or not.
A cycle in a linked list occurs when a node's next
points back to a previous node in the list. T...read more
Q40. Angle Calculation Between Clock Hands
Given a specific time in hours and minutes, your task is to calculate the smallest possible angle between the hour hand and the minute hand of a clock.
Example:
Input:
T = ...read more
Q41. Quadratic Equation Root Finder
Given three integers A
, B
, and C
representing the coefficients of a quadratic equation A*X^2 + B*X + C = 0, your task is to determine the real roots of the equation. If no real ro...read more
Q42. LRU Cache Design Question
Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:
1. get(key)
- Return the value of the key if it exists in the cache; otherwise, re...read more
Q43. Diagonal Traversal of a Binary Tree
You are provided with a binary tree composed of integers. Your task is to determine all the diagonal paths within the binary tree. A diagonal path is defined as a sequence of...read more
Q44. Binary Search Tree Insertion
Given the root node of a binary search tree and a positive integer, you need to insert a new node with the given value into the BST so that the resulting tree maintains the properti...read more
Q45. Palindrome Partitioning Problem Statement
Given a string S
, the task is to partition S
so that every substring in the partition is a palindrome. Return all possible palindrome partitions of S
.
Example:
Input:
S...read more
Q46. Number of Islands Problem Statement
You are provided with a 2-dimensional matrix having N
rows and M
columns, containing only 1s (land) and 0s (water). Your goal is to determine the number of islands in this ma...read more
Q47. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Q48. Possible Words From A Phone Number
After years of research, Ninja has invented a time machine and found himself in the era where T9 keypads were commonly used in mobile phones. Being curious, Ninja seeks to det...read more
Q49. Find K'th Character of Decrypted String
You are given an encrypted string where repeated substrings are represented by the substring followed by its count. Your task is to find the K'th character of the decrypt...read more
Q50. Ninja's Dance Competition Pairing Problem
Ninja is organizing a dance competition and wants to pair participants using a unique method. Each participant chooses a number upon entry, and Ninja selects a number ‘...read more
Q51. Reverse Stack with Recursion
Reverse a given stack of integers using recursion. You must accomplish this without utilizing extra space beyond the internal stack space used by recursion. Additionally, you must r...read more
Q52. Minimum Operation Needed to Convert to the Given String
You are given two strings str1
and str2
. Determine the minimum number of operations required to transform str1
into str2
.
Explanation:
An operation is def...read more
Q53. Flatten the Multi-Level Linked List
You are provided with a multi-level linked list containing N
nodes. Each node has pointers next and child, which could potentially point to additional nodes. The task is to f...read more
Q54. Valid Parentheses Problem Statement
Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.
Input:
The first line contains an integer...read more
Q55. Boundary Traversal of a Binary Tree
Given a binary tree of integers, your task is to return the boundary nodes of the tree in Anti-Clockwise direction starting from the root node.
Input:
The first line contains...read more
Q56. Most Frequent Word Problem Statement
You are given two strings 'A' and 'B' composed of words separated by spaces. Your task is to determine the most frequent and lexicographically smallest word in string 'A' th...read more
Q57. Regular Expression Match Problem Statement
Given a string str
and a string pat
, where str
may contain wildcard characters '?' and '*'.
If a character is '?', it can be replaced with any single character. If a c...read more
Q58. Infix to Postfix Conversion
Convert a given infix expression, represented as a string EXP
, into its equivalent postfix expression.
Explanation:
An infix expression is formatted as a op b
where the operator is p...read more
Q59. Division to N Decimal Places
Your task is to compute the division of two integers, X / Y, and output the result formatted to contain exactly N decimal places.
Input:
The first line contains an integer ‘T’, repr...read more
- Assumptions
- System considerations
- Design components
Q63. minimum number of operations required to set all elements of a binary matrix
The minimum number of operations required to set all elements of a binary matrix to 0 or 1.
Count the number of 0s and 1s in each row and column separately.
For each row and column, choose the minimum between the count of 0s and 1s as the number of operations needed.
Sum up the minimum operations for all rows and columns to get the total minimum operations.
Q64. Print all permutations of a string
Print all permutations of a string
Use recursion to swap each character with every other character in the string
Repeat the process for the remaining characters
Stop when there are no more characters to swap
Use a set to avoid duplicates
Q66. What is ts & why we should use over js
TypeScript (ts) is a superset of JavaScript (js) that adds static typing and other features to improve code quality and maintainability.
TypeScript provides static typing, which helps catch errors at compile time rather than runtime.
TypeScript supports modern JavaScript features like classes, interfaces, and modules.
TypeScript can be transpiled into JavaScript, making it compatible with all browsers and environments.
TypeScript has a rich ecosystem with tools like TypeScript co...read more
More about working at Microsoft Corporation
Interview Process at Ray International Llc Oman
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month