Optum Interview Questions
UnitedHealth Group is a subsidiary of Optum. The three main businesses that comprise the Optum brand are OptumHealth, OptumInsight, and OptumRx. An industry-leading provider of digital health technologies in India, because of their extensive knowledge, cutting-edge analytics, and technology, they are able to assist their clients in driving sustainable health economics and more tailored treatment.
Optum is an outstanding company to work for since it provides its employees with opportunities to learn new skills, the management is friendly, and there is a good balance between work and personal life. Optum is committed to fostering the engineering talent of the future. Because the company's training programme focuses on learning the most cutting-edge technology in the information technology field, working there is a lot of fun.
In this article, we will see the commonly asked Optum Interview Questions, its recruitment process, tips on how to prepare for it as well a few common FAQs.
Optum Recruitment Process
1. Interview Process
- Aptitude Written Test Online
- Group Discussion
- Technical Interview
- HR Interview
2. Interview Rounds
- Aptitude Written Test Online: You must take an aptitude exam if you want to work for an Optum company. The test might be different depending on the job you're applying for, but there are tests for educational fields like coding, math, English language, and critical thinking. The same exam might also be used for other disciplines.
- Group Discussion: This is a common procedure for filtering candidates. The group is chosen by a judge and is split into several teams. A common theme is selected for the group to discuss. Students are judged on their knowledge, communication abilities, leadership abilities, and retention abilities in the GD round. You must update yourself on the latest news and current affairs in the GD round.
- Technical Interview: In this round, you will test your knowledge in relation to the topic you are studying, like data structures and algorithms, databases, problem-solving, OS, CN, and other important technical knowledge that will be relevant to your profession. It may be conducted in a group or individually, but if time is short, it may be conducted as a group. You will be assessed on your confidence and abilities in this round. This job interview might be your first real professional experience, or you may have worked on real industry jobs or interned for short periods of time. It will help you do well in this interview if you have worked in real-world jobs or participated in real-world projects. If you have worked in the industry or participated in real-world tasks, this interview may be easier for you to ace.
- HR Interview: In the HR screening phase, human resources specialists want to get a feel for your previous roles, core competencies, key strengths and limitations, and salary expectations by asking questions. If you have passed the formal inquiry, you will receive an offer letter and a post-placement discussion. You will be given instructions and informed about the joining procedure, as well as any other important information.
Optum Technical Interview Questions: Freshers and Experienced
1. What is Object Cloning?
An exact copy of an object is created using the clone() method of the object class. To create a perfect clone of an object, the Cloneable interface must be implemented by a class that defines its object clone.
2. What is Object Oriented Programming?
Oops, a type of programming that focuses on objects rather than just functions and procedures, is based on classes instead of just functions and procedures. Inheritance, polymorphism, hiding, and other real-world entities are used in OOPs. It also allows for binding data and code together.
3. To determine whether an integer x is a palindrome, simple return true or false, if it is. A palindrome is an integer that reads the same backwards as forwards. For example, 121 is a palindrome while 123 is not.
Example 1:
- Input: x = 121
- Output: true
Explanation: 121 reads as 121 from left to right and from right to left.
Example 2:
- Input: x = -121
- Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore, it is not a palindrome.
Example 3:
- Input: x = 10
- Output: false
Explanation: Reads 01 from right to left. Therefore, it is not a palindrome.
We want to see whether the lower half of x equals the higher half of x, for example, when x = 1234321, we wish to ascertain whether 123 equals 123, The only pertinent situation is where x is unspecified, as can be seen by the examples. If x is, for example, 0, then it's very evident that it is not a Palindrome, so we may simply return true.
public class Solution {
public boolean isPalindrome(int x) {
if(x == 0)
return true;
if(x < 0 || x % 10 == 0)
return false;
int v = 0;
while(x > v) {
v = x % 10 + v * 10;
x = x / 10;
}
return x == v || v / 10 == x;
}
}
Learn via our Video Courses
4. Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Example 1:
- Input: haystack = "hello", needle = "ll"
- Output: 2
Example 2:
- Input: haystack = "aaaaa", needle = "bba"
- Output: -1
We use the KMP string matching algorithm, which performs this task in linear time. We need to preprocess and create an LPS array in which lps[i] refers to the longest possible prefix that is also a suffix.
class Solution {
public:
// calculate the lps function
vector<int> calc(string pat, int m)
{
vector<int> lps(m,0);
int i=1, j=0;
while(i<m){
if(pat[i]==pat[j]){
j++;
lps[i++]=j;
}
else{
if(j) j=lps[j-1];
else lps[i++]=0;
}
}
return lps;
}
int strStr(string haystack, string needle) {
int n=haystack.length(), m=needle.length();
if(m==0) return 0;
vector<int> lps = calc(needle, m);
int i=0,j=0;
while(i<n && j<m){
if(haystack[i]==needle[j]){
i++;
j++;
}
if(j==m) return i-j; // since we are returning the first valid index, we just return i-j. If we had to return all valid indices, then we would have to do j=lps[j-1] after this step, since pattern can repeat, and the new pattern may already have started.
else if(i<n && j<m && haystack[i]!=needle[j]){
if(j) j=lps[j-1];
else i++;
}
}
return -1;
}
};
5. A simple algorithm can be developed to detect whether or not a given integer fits into a sorted array of distinct values. If the target value is not found, then return the index at which it would be inserted in order.
You must design an algorithm with a Log(n) runtime complexity.
Example 1:
- Input: nums = [1,3,5,6], target = 5
- Output: 2
Example 2:
- Input: nums = [1,3,5,6], target = 2
- Output: 1
Example 3:
- Input: nums = [1,3,5,6], target = 7
At the start of the binary search, the array is checked to see if its edges include the target, and the rest of the process follows the same steps as the binary search. However, binary search also checks to see if the target is between the value lower and higher than the mid in order to ensure that the target is found.
class Solution {
public:
int searchInsert(vector<int>& nums, int target) {
if(nums.front() >= target) return 0;
if(nums.back() == target) return nums.size()-1;
if(nums.back() < target) return nums.size();
int low = 0;
int high = nums.size();
int mid = 0;
while(low < high) {
mid = (low + high) / 2;
if(nums[mid] == target) return mid;
if(nums[mid-1] < target && nums[mid] > target) return mid;
else if(nums[mid] < target) low = mid;
else high = mid;
}
return mid;
}
6. What is a prototype chain?
A prototype chain is used to create new types of things based on existing ones. It is similar to inheritance in a class-based language. The prototype on object instance is accessible via Object.getPrototypeOf(object) or proto property, and the prototype on constructors function is accessible via Object.prototype.
7. What are lambda or arrow functions?
Arrow functions, which do not have their own this, arguments, super, and new.target, are a shorter syntax for a function expression and do not have their own this, arguments, super, or new.target. Non-method functions are what these functions are best suited for, and they cannot be used as constructors.
8. What is a service worker?
A service worker (JavaScript file) is a piece of code that runs in the background and provides features that don't require a web page or user action. Some of the most significant service worker features are offline-first web application development, periodic background, push notifications, interception, and programmatic management of a cache of responses.
9. How do you reuse information across service worker restarts?
You cannot rely on the global state within a service worker's onfetch and onmessage handlers because they terminate and restart the service worker when it is not in use or when it is next needed, respectively. This is because service workers are able to persist and reuse IndexedDB API across restarts.
10. What is a post message?
Cross-origin communication between Window objects (e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it) using Post message is possible. Scripts on different pages are allowed to communicate if and only if they adhere to the same-origin policy (i.e., they share the same protocol, port number, and host).
11. To determine and return the square root of an unspecified integer x, compute and return x. Because the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.
Because the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.
Example 1:
- Input: x = 4
- Output: 2
Example 2:
Input: x = 8
Output: 2
Explanation: The square root of 8 is 2.82842..., and since the decimal part is truncated, 2 is returned.
We are converging to the closest value using binary search, so we return high because high will always be the truncated value. Since we are converging to the closest value using binary search, we return high because high will always be the truncated value. In the case of a perfect square we will end with our mid pointer at the solution, and in the case of not a perfect square high pointer will end at the floor value because it was moving towards the lower side. If we were to find the ceil value, we would have considered the low pointer as it was going higher and we would have returned low. The code is:
class Solution {
public:
int mySqrt(int num) {
long unsigned int l = 1, h = num,mid;
while(l <= h)
{
mid = l + (h - l)/2;
if(mid * mid == num)
return mid;
else if(mid * mid > num)
h = mid - 1;
else l = mid + 1;
}
return h;
}
};
12. What are server-sent events?
A browser using server-sent events (SSE) is able to receive automatic updates from a server via an HTTP connection without having to go through a polling procedure. These are one-way communications, in which events flow from the server to the client only. For example, stock price updates, Facebook/Twitter updates, and news feeds have been employed.
13. What is a strict mode in javascript?
A program, function, or other apps can be put into a strict operating context with the new Strict Mode feature in ECMAScript 5. The browser will therefore prevent certain actions from being performed and throw more errors. The literal statement "use strict"; tells the browser to use the JavaScript code in the Strict mode.
14. Why do you need strict mode?
By disabling strict mode, you can make sure that your JavaScript is "secure" by not emitting "bad syntax" warnings. For example, it suppresses the generation of a global variable if an error is thrown and also generates an error for assignments to non-writable properties, getters-only properties, non-existing properties, non-existing variables, and non-existing objects.
15. What is event bubbling?
An event bubbling technique is a kind of event propagation that starts with the innermost target element, and then successively triggers on the subsequent ancestors (parents) of the target element inside the same hierarchical context until the outermost DOM element is reached.
16. What is event capturing?
A type of event propagation that involves the event first being captured by the outermost element and then being transmitted to the child elements of the target element in the same hierarchical structure until it reaches the innermost DOM element.
17. A statement is considered a palindrome if it reads the same both forward and backwards after all uppercase letters have been changed to lowercase and all non-alphanumeric characters have been eliminated.
There are letters and numbers among alphanumeric characters. Return true or false depending on if the string s is a palindrome when one is provided.
Example 1:
- Input: s = "Do geese see God"
- Output: true
Explanation: "dogeeseseegod" is a palindrome.
Example 2:
- Input: s = "hello world"
- Output: false
Explanation: "helloworld" is not a palindrome.
Example 3:
- Input: s = " "
- Output: true
Explanation: After deleting all of the characters that are not alphanumeric, s is left as an empty string "". A palindrome is a string that may be read either forward or backwards and yet produce the same meaning.
We first created a string in which we could store the alphanumeric characters(e.g 0 to 9, a, b, c, etc). We separated the alphanumeric characters using the characters from the specific ASCII value range. Then we used the palindrome function(two pointers) to obtain them back again.
bool isPalindrome(string s) {
string b;
for(int i=0;i<s.length();i++){
if((s[i]>=65 && s[i]<=90))
b.push_back(s[i]+32);
else if(s[i]>=97 && s[i]<=122)
b.push_back(s[i]);
else if(s[i]>=48 && s[i]<=57)
b.push_back(s[i]);
}
int i=0,j=b.length()-1;
while(i<=j){
if(b[i]!=b[j]){
return false;
}
i++;
j--;
}
return true;
}
18. Given an array nums of size n, determine the element that appears more than ⌊n / 2⌋ times. You may assume that the element that appears more than ⌊n / 2⌋ times always exists in the array.
Example 1:
- Input: nums = [3,2,3]
- Output: 3
Example 2:
- Input: nums = [2,2,1,1,1,2,2]
- Output: 2
We start by initialising the ans variable with the array index 0 and starting at 1. We then check if the ans variable equals the current element each time it is reached. It is incremented if the variable is equal to the current element and it is decremented if it is not. This method works because it is more efficient to increase the number of increments than decrease the number of decrements.
class Solution {
public:
int majorityElement(vector<int>& nums) {
int count=0, ans;
for(int i=0;i<nums.size();i++){
if(count==0){
ans=nums[i];
count=1;
continue;
}
if(ans!=nums[i])
count--;
else
count++;
}
return ans;
}
};
19. Reverse bits of a given 32 bits unsigned integer.
Example 1:
- Input: n = 00000010100101000001111010011100
- Output: 964176192 (00111001011110000010100101000000)
Explanation:
The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000.
Example 2:
- Input: n = 11111111111111111111111111111101
- Output: 3221225471 (10111111111111111111111111111111)
Explanation:
The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 whose binary representation is 10111111111111111111111111111111.
The problem asks for a swap that swaps each pair of bits from the outside in. The swap operation looks at the pair of bits and flips each bit if it is different. We can select the ith bit and the jth bit with the expression (n >> i) & 1 and (n >> j) & 1. We then compare the two bits.
If they are equal, we don't have to do anything because swapping them would have no effect. If they're not equal, we XOR each bit with 1. This causes the bits to be swapped even though we're flipping them only to XOR them.
In the example (0, 1) would get changed to (1, 0) and (1, 0) to (0, 1) while (1, 0) and (1, 0) would become (0, 1). We can XOR each bit with ones by ORing the ith and jth bits with 1's. ((1U i) | (1U j)). Using our number to flip the ith and jth bits, we can XOR it with our number. To flip the bits in the ith and jth places, we can XOR our number with the ith and jth bits. The table can be thought of as a list of numbers p.
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
int i = 0, j = 31;
while (i < j) {
if (((n >> i) & 1) != ((n >> j) & 1)) {
n ^= ((1U << i) | (1U << j));
}
i++, j--;
}
return n;
}
};
20. Create a function that returns the Hamming weight of an unsigned integer (also known as the number of '1' bits).
Example 1:
- Input: n = 00000000000000000000000000001011
- Output: 3
Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits.
Example 2:
- Input: n = 00000000000000000000000010000000
- Output: 1
Explanation: The input binary string 00000000000000000000000010000000 has a total of one '1' bit.
Example 3:
- Input: n = 11111111111111111111111111111101
- Output: 31
Explanation: The input binary string 11111111111111111111111111111101 has a total of thirty one '1' bits.
In order to check if the last bit is 1 in a binary number, we must count the number of bits. We must also check if the last bit is 1. If it is 1, we must add it to our total. We can test this by inverting our number and checking if the last bit is 1. If the last bit is 1, we will add it to our total. We can invert our number up to 5 and check if it is 1.
class Solution {
public:
int hammingWeight(uint32_t n) {
int total=0;
while(n!=0){
if(n%2==1)
total++;
n=n>>1;
}
return total;
}
};
21. What is the difference between document load and DOMContentLoaded events?
The DOMContentLoaded event takes place after the DOM tree has been updated with all of the page's nodes after they have been added. When all of the resources, including graphics and sub-frames, have been fully loaded, the load event is triggered.
22. What is inheritance?
Let's use the analogy of traffic on the road to illustrate what inheritance is all about. This traffic has a few characteristics in common. It is made up of objects that are able to travel along the road and carry people as well as commodities from one location to another. These items are referred to as automobiles. These vehicles are distinct from one another in a number of respects, including but not limited to whether they are used to carry people or products, the maximum number of passengers that can be carried at one time, whether they are two-wheelers or four-wheelers, etc. As a result, we have a wide variety of vehicles, including automobiles, bicycles, scooters, auto-rickshaws, buses, and trucks, amongst others. As can be seen in the following example, we can use inheritance to represent this flow. In this context, the Vehicle is the foundational class that contains the behaviours and features that are shared by all Vehicles. After that, we have the subcategories of Vehicles, which include Automobiles, Bicycles, Buses, and Trucks.
23. What is polymorphism?
Polymorphism means having different looks. In simple terms, polymorphism means that a message can be displayed in more than one way. Having a variety of different forms is what is meant by the term polymorphism. The capacity of a message to be presented in more than one form is an example of polymorphism, which we may explain using more straightforward language.
Polymorphism is a case study drawn from real life: Different aspects of a person may coexist inside the same body at the same time. In the same way a guy simultaneously fulfils the roles of parent, husband, and worker. Therefore, the same individual might exhibit quite diverse behaviours depending on the context in which they are found. This phenomenon is known as polymorphism.
In object-oriented programming, polymorphism is often regarded as one of the most essential characteristics to have. Polymorphism gives us the ability to carry out a single activity in a number of distinct ways. To put it another way, polymorphism gives you the ability to create only one interface while yet supporting various implementations. Because "poly" means numerous and "morphs" implies forms, this term refers to a large number of different forms.
24. What is static polymorphism?
Like many other OOP languages, Java enables the implementation of several methods with the same name in the same class. Java, however, has a separate set of parameters known as method overloading, which is a static variation on polymorphism. At least one of the following three criteria must be different between the parameter sets: They must each accept a different number of parameters; one method must take two parameters, while the other must accept three. The argument types must differ, with one method taking a String and another accepting a Long. They must anticipate the parameters in a different sequence. One method, for example, takes a String and a Long, whereas another accepts a Long and a String. This type of overloading is not advised since it complicates the API's understanding.
In most situations, each of these overloaded methods gives a unique but fairly comparable set of capabilities. Each method has a unique signature due to the various argument sets. This signature instructs the compiler on the method to invoke and ties it to the method call. This method is known as static binding or static polymorphism.
One method through which Java provides static polymorphism is method overloading. The argument list at compile time determines which of these two definitions of the identical function add() will be invoked. This phenomenon is sometimes referred to as compile-time polymorphism for this reason.
25. What is dynamic polymorphism?
This type of polymorphism prevents the compiler from determining the executed method. At runtime, the JVM must perform this function. Within an inheritance hierarchy, a subclass can override a method of its superclass, allowing the subclass's developer to alter or fully change the method's behaviour. This results in a type of polymorphism. The names and parameters of the methods implemented by the super- and subclasses are the same. They do, however, serve diverse purposes.
We have two classes in this example: ABC and XYZ. XYZ is a kid class, whereas ABC is a parent class. The parent class's myMethod() function is being replaced with that of the child class. In this example, the child class object has been assigned to the parent class reference, therefore the type of the object will be identified at run-time in order to identify which method will be invoked. Which version of the method would be invoked depends on the kind of object (not the type of reference).
26. What is Late binding?
You may wish to employ an inheritance hierarchy in your project at times. To do this, you must respond to the question, "Which method will the JVM call?" Because it is dependent on the object on which the method is called, the response appears at runtime. The kind of reference, as shown in your code, is immaterial. You must differentiate three broad scenarios: Your object is of the superclass's type and is referred to as such. So, in this post's example, a BasicCoffeeMachine object is referred to as a BasicCoffeeMachine. Your object is of the subclass's type and is referred to as such. In this post's example, a PremiumCoffeeMachine object is referred to as a PremiumCoffeeMachine. Your object is of the subclass type and is referred to as the superclass. A PremiumCoffeeMachine object is referred to as a BasicCoffeeMachine in the CoffeeMachine example.
27. What is method overloading?
One of the most helpful characteristics of an Object-Oriented Language is method overloading in Java. It allows for several methods with the same name in a class. The only difference between these methods is the list of arguments that are supplied through them. With a simple example, it is easy to understand. A class addition contains two add() methods, one with two integer parameters, int a and int b, and the other with three integer parameters, int a, int b, and int c. As a result, the add() function is overloaded. The method that is called will be determined by the number of arguments given in the method-calling statement. For example, add(20,30) will invoke the add() function with two parameters, but add(10,20,30) will invoke the add method with three parameters.
28. What is method overriding?
Method overloading allows the method to have the same name but have different parameters or argument types. It is linked to compile-time polymorphism. The following are some considerations to bear in mind while overloading methods in Java. A return type cannot be overloaded. Although static methods can be overloaded, the arguments or input parameters must be distinct. We cannot overload two methods that vary solely by a static keyword. The main() function, like other static methods, can be overloaded.
29. What's the distinction between native, host, and user objects?
Native objects are objects that are described by the ECMAScript standard as being part of the JavaScript language. String, Math, RegExp, Object, Function, and other ECMAScript basic objects are examples. Host objects are those made available by the browser or runtime environment (Node). Host objects include windows, XmlHttpRequest, DOM nodes, and so on. User objects are objects that have been defined in the javascript code. User objects, for example, are built for profile information.
30. Create an algorithm to assess if a number n has content. A happy number is one that is defined by the following procedure: Begin with any positive integer and replace it with the sum of its digit squares.
Repeat the procedure until the number equals 1 (where it will remain), at which point it will run indefinitely in a cycle that does not contain 1. Those numbers whose procedure results in a 1 are content. If n is a happy number, return true; otherwise, return false.
Example 1:
- Input: n = 19
- Output: true
- Explanation:
1^2 + 9^2 = 82
8^2 + 2^2 = 68
6^2 + 8^2 = 100
1^2 + 0^2 + 0^2 = 1
Example 2:
- Input: n = 2
- Output: false
We can keep track of the numbers using a map. This is analogous to identifying a loop. if a number has previously been computed It suggests we're stuck in a rut. I used a string to make it easier to handle the numbers (the number has a limit of 231). If the number has already been discovered, we return false; otherwise, we generate a new number. Using the string We interrupt the loop and return true when the number is 1.
unordered_map<int,bool>map;
bool isHappy(int n) {
while(n!=1)
{
string s = to_string(n);
if(map[n]==true)
{
return false;
}
else{
map[n] = true;
n=0;
for(auto i:s)
n+=(i-'0')*(i-'0');
}
}
return n==1;
}
31. Determine whether two strings, s and t, are isomorphic. If the characters in s can be changed to produce t, two strings s and t are isomorphic.
All instances of a character must be replaced with another character while maintaining the character's order. A character cannot map to another character, but it may map to itself.
Example 1:
- Input: s = "egg", t = "add"
- Output: true
Example 2:
- Input: s = "foo", t = "bar"
- Output: false
Example 3:
- Input: s = "paper", t = "title"
- Output: true
The goal is to map each character in s to the corresponding character in t, unless the character has previously appeared, in which case we check to see if it mapped to the same value as the current character, and return false if it didn't. Also, two characters in t may not map to the same character in s, which is why we keep track of all the characters that have appeared in t in their own set, and verify that the character hasn't yet appeared if its corresponding character in s hasn't as well.
class Solution {
public:
bool isIsomorphic(string s, string t) {
if (s.size() != t.size())
return false;
unordered_map<char, char> hash;
unordered_set<char> tChars;
for (int i = 0; i < s.size(); ++i)
{
if (hash.count(s[i]))
{
if (hash[s[i]] != t[i])
return false;
}
else
{
if (tChars.count(t[i]))
return false;
hash[s[i]] = t[i];
tChars.insert(t[i]);
}
}
return true;
}
};
32. Return true if the number n is a power of two. Return false otherwise. If there exists an integer x such that n == 2x, then n is a power of two.
Example 1:
- Input: n = 1
- Output: true
- Explanation: 20 = 1
Example 2:
- Input: n = 16
- Output: true
- Explanation: 24 = 16
Example 3:
- Input: n = 3
- Output: false
If n is a negative integer or zero, the function returns false (self-explanatory). All powers of two have only one bit set in their binary form, for example, 2 -> 1 0, 16 -> 1 0 0 0 0. So we use the (__builtin popcount()) method, which returns the number of set bits (1) and if it equals 1 then the number is a power of two, else it is not.
class Solution {
public:
bool isPowerOfTwo(int n) {
if(n<1) return false;
else if(__builtin_popcount(n)==1) return true;
else return false;
}
};
33. You are provided a unique integer array nums that is sorted. A range [a,b] is the collection of all integers between a and b. (inclusive). Return the shortest sorted list of ranges that exactly cover all of the integers in the array.
That is, each element of nums is covered by precisely one of the ranges, and no integer x exists in which x is in one of the ranges but not in nums.
Example 1:
- Input: nums = [0,1,2,4,5,7]
- Output: ["0->2", "4->5", "7"]
- Explanation: The ranges are:
[0,2] --> "0->2"
[4,5] --> "4->5"
[7,7] --> "7"
Example 2:
- Input: nums = [0,2,3,4,6,8,9]
- Output: ["0", "2->4", "6", "8->9"]
- Explanation: The ranges are:
[0,0] --> "0"
[2,4] --> "2->4"
[6,6] --> "6"
[8,9] --> "8->9"
We are provided with unique integer array nums that are sorted.
We must produce the lowest list of ranges that exactly cover all of the numbers in the array. nums = [0,1,2,4,5,7] as input ["0->2", "4->5", "7"] as output So, for the first iteration, our for loop will iterate from 0 to n (n being the vector size) and assign a = nums[i]. Now, for the first iteration, I = 0, we are looking for a condition that says if our I == n-1 or nums[i] + 1!= nums[i+1]. As a result, for the first repetition, 0!= 5 or 1!= 1 ( none of them is true) False condition. In the second iteration, I = 1; 1!= 5 or 2!= 2. (none of them is true) False condition, In the third iteration, I = 2; 2!= 5 or 3!= 4. (both are true) True Condition. So it will now execute under the For Loop for the first time. Now, if the condition in the for loop specifies that 2!= 0, we will push a -> nums[i] in the result; You are provided with a unique integer array of nums that are sorted. A range [a,b] is the collection of all integers between a and b. (inclusive). Return the shortest sorted list of ranges that exactly cover all of the integers in the array. That is, each element of nums is covered by precisely one of the ranges, and no integer x exists in which x is in one of the ranges but not in nums.
class Solution {
public:
vector<string> summaryRanges(vector<int>& nums) {
// resultant string
vector<string> result;
int n = nums.size();
// if size happens to be zero return empty string
if(n == 0 )
return result;
// assigning first element to a
int a = nums[0];
for(int i = 0; i<n; i++)
{
// if one of both is true
if( i == n-1 || nums[i]+1 != nums[i+1])
{
// if current element is not equals a
// this means we have found a range.
if(nums[i] != a)
result.push_back(to_string(a)+ "->"+ to_string(nums[i]));
// this means we have reached to the end of string and now
// we have to add a that should be the last element
else
result.push_back(to_string(a));
// checking for this condition so that a got updated for next range
// also n-1 so that a doesn't contain out of bound value
if(i != n-1)
a = nums[i+1];
}
}
// return result
return result;
}
};
34. Return true if t is an anagram of s, and false otherwise, given two strings s and t. An anagram is a word or phrase created by rearranging the letters of another word or phrase, usually utilising all of the original letters precisely once.
Example 1:
- Input: s = "anagram", t = "nagaram"
- Output: true
Example 2:
- Input: s = "rat", t = "car"
- Output: false
The goal is to see if s and t have the same characters. We use an unordered map charMap (hashtable) to map a character to the frequency with which it appears in s. In the second step, we loop over t to see if all of its characters have a frequency greater than one in charMap. If the character frequency is equal to zero, we delete this charMap record. We know that t is not an anagram of s if a character is not present. Finally, we ensure that all characters in charMap have been "used" in t by verifying whether charMap is empty.
class Solution {
public:
bool isAnagram(string s, string t) {
unordered_map<char, int> charMap;
for (int i = 0; i < s.size(); i++){
charMap[s[i]]++;
}
for (int i = 0; i < t.size(); i++){
if (charMap.count(t[i]) == 0){
return false;
}
charMap[t[i]]--;
if (charMap[t[i]] <= 0){
charMap.erase(t[i]);
}
}
return charMap.empty();
}
};
35. You are a product manager in charge of a team working on a new product. Unfortunately, the most recent version of your product does not pass the quality check.
Because each version is built on the preceding version, all versions following a poor version are also awful. Assume you have n versions [1, 2,..., n] and wish to locate the first poor one that causes all the subsequent ones to be bad. The API bool isBadVersion(version) returns if the version is bad. Create a method to locate the earliest problematic version. You should make as few API requests as possible.
Example 1:
- Input: n = 5, bad = 4
- Output: 4
- Explanation:
call isBadVersion(3) -> false
call isBadVersion(5) -> true
call isBadVersion(4) -> true
Then 4 is the first bad version.
Example 2:
- Input: n = 1, bad = 1
- Output: 1
The issue may be handled by iterating through all of the products from 1 to n and accessing the API to determine if each product is excellent or poor. However, because we are being requested to reduce the number of API calls, which is a significant aspect of the efficiency of an application in software development, we must devise a better solution. If the description above sparked the thought of a binary search in your mind, you are perfectly correct, my buddy. It is a basic implementation of binary search, except that we are given a function to call instead of an array to utilise its values. So, as normal, we compute the mid-value and then call the API isBadVersion(mid); if it returns a negative result, we are in the zone of defective products and must change or search space to (mid-1), since mid is already a faulty product. We then add this mid to our "res" variable, which maintains track of the defective product's initial index. If the API request returns yes, we are in the range of a decent product and must now change our search space's left index to mid+1.
class Solution {
public:
int firstBadVersion(int n) {
//we have to search from [1,2,....,n] so appoint left = 1 and right = n
int l = 1, r = n;
while(l<=r) {
//this is same as (l+r)/2 just prevent overflowing
int m = r+(l-r)/2;
// if m = 1 and it is bad then its first bad version or if m is bad and m-1 is not bad then its first bad version
if((m == 1 && isBadVersion(m)) || isBadVersion(m) != isBadVersion(m-1))
return m;
else if(!isBadVersion(m)) //if m is not bad then we have to search in right side
l = m+1;
else // if m is bad then we have to search at left side to find first bad version
r = m-1;
}
//if not bad version found
return -1;
}
};
36. Move all 0s to the end of an integer array nums while keeping the relative order of the non-zero members. It is important to note that you must accomplish this in-place, without producing a duplicate of the array.
Example 1:
- Input: nums = [0,1,0,3,12]
- Output: [1,3,12,0,0]
Example 2:
- Input: nums = [0]
- Output: [0]
The method used is a two-pointer algorithm that reads and writes pointers. Traverse all the integers in the input array, and if the current num is not zero, write the current value to the index pointed by write ptr; otherwise, do nothing.
void moveZeroes(vector<int>& nums) {
// Base case: If the input is empty
if (nums.empty()) {
// input is empty, nothing to process
return;
}
// Initialize read and write indices that initalizes to 0
int rIdx = 0;
int wIdx = 0;
// Variable to store number of zeros
int numzeros = 0;
// Traverse the loop for all input numbers
while (rIdx < nums.size()) {
// Check whether the current number is zero or not
if (nums[rIdx] != 0) {
// Current number is not zero, push it to the write
// index
nums[wIdx++] = nums[rIdx];
}
else{
// The current number is a zero, increment the count
numzeros++;
}
// Increment the read index
rIdx++;
}
// Fill the zeros at the end of array
while (numzeros--) {
nums[wIdx++] = 0;
}
return;
}
37. Determine whether a pattern and a string s follow the same pattern. A full match indicates that there is a bijection between a letter in pattern and a non-empty word in s.
Example 1:
- Input: pattern = "abba", s = "dog cat cat dog"
- Output: true
Example 2:
- Input: pattern = "abba", s = "dog cat cat fish"
- Output: false
Example 3:
- Input: pattern = "aaaa", s = "dog cat cat dog"
- Output: false
The words in s will be mapped to their corresponding letters in the pattern. If pattern[i] already exists, see if s[i] is the same as pattern[i]. Let's utilise hashmaps to map pattern[i] and worlds in "s." Because the words are provided by a single string s, we may build another array of strings to hold all of them for ease of implementation. Iterate over the string s and insert the word into our string array if there is space.
string String_toOrder(map <string, char>& str_map, string s) {
char cur_label = 'a';
string word, output;
for(int i = 0; i <= s.length(); i++) {
if(s[i] == ' ' || i == s.length()) {
if(str_map.find(word) == str_map.end()) str_map[word] = cur_label++;
output += str_map[word];
word = "";
} else word += s[i];
}
return output;
}
string Pattern_toOrder(map <char, char>& pat_map, string pattern) {
char cur_label = 'a';
string output;
for(int i = 0; i < pattern.length(); i++) {
if(pat_map.find(pattern[i]) == pat_map.end()) pat_map[pattern[i]] = cur_label++;
output += pat_map[pattern[i]];
}
return output;
}
bool wordPattern(string pattern, string s) {
map <string, char> StringMap;
map <char, char> PatternMap;
string Pattern_InOrder = Pattern_toOrder(PatternMap, pattern);
string String_InOrder = String_toOrder(StringMap, s);
return Pattern_InOrder == String_InOrder;
}
38. You are now engaged in the following activities: Nim Play this game with a friend: At first, there is a pile of stones on the table. You and your pal will take turns, and you will go first.
The individual whose turn it is will take 1 to 3 stones from the stack on each round. The winner is the person who removes the last stone. Return true if you can win the game providing both you and your companion play optimally, else return false.
Example 1:
- Input: n = 4
- Output: false
Explanation:
These are the possible outcomes:
1. You remove 1 stone. Your friend removes 3 stones, including the last stone. Your friend wins.
2. You remove 2 stones. Your friend removes 2 stones, including the last stone. Your friend wins.
3. You remove 3 stones. Your friend removes the last stone. Your friend wins.
In all outcomes, your friend wins.
Example 2:
- Input: n = 1
- Output: true
Example 3:
- Input: n = 2
- Output: true
If there is only one stone, I shall begin by taking it. I'll be the victor.
If there are two stones, I can take both and win since a person is permitted to take up to three stones. Similarly, if three stones are there, I will win. However, if there are four stones and I am the first to begin, I can only take three. So, after my turn, my friend will be left with the last stone, giving him victory. Similarly, if there are 8 stones, my friend will always grab the final stone. As you can see, this pattern repeats itself. You lose when the number of stones present is a multiple of four. So all we have to do is determine if 'n' is a multiple of four. If true, either return 0 (since you lost) or return 1. (since you won).
class Solution {
public:
bool canWinNim(int n) {
return n%4;
}
};
39. Return true if the number n is a power of three. Return false otherwise. If there exists an integer x such that n == 3^x, then n is a power of three.
Example 1:
- Input: n = 27
- Output: true
Example 2:
- Input: n = 0
- Output: false
Example 3:
- Input: n = 9
- Output: true
If there is a power of three numbers, it will always conclude with 3, 9, 7, or 1. If a number finishes with one of these four digits, we just need to verify the powers of three to ensure that the number ends with that digit. If a given number ends in 1, it must be a 4th, 8th, 12th, and so on power of three, if at all. Now that we've established the observations, let's have a look at the method. If the provided number, n, does not finish with 3,9,7, or 1, it is not a power of three and should be returned as FALSE. If not, we establish a Map with four entries to keep the mapping between the powers of three (1,2,3,4) and the number's last digits (3,9,7,1). Look for the equivalent power in the map using the final digit of a given integer. Return TRUE if this power, when increased to three, equals the number, n. If the power raised to three is less than the number n, increase the power straight by 4 and repeat step 4 until the power raised to three exceeds n. If the power of three is greater than the supplied number, return FALSE.
class Solution {
public:
bool isPowerOfThree(int n) {
if(n <= 0)
return false;
while(n % 3 == 0)
{
n = n / 3;
}
return n == 1;
}
};
40. What is BOM?
JavaScript may "speak to" the browser via the Browser Object Model (BOM). It is made up of the window's children, navigator, history, screen, location, and document. The Browser Object Model is not standardized and might vary depending on the browser.
41. Why is JavaScript treated as Single threaded?
JavaScript is a single-threaded programming language. Because the language specification does not let the programmer write code that can be executed in parallel by the interpreter in many threads or processes. Unlike languages such as Java and Go, C++ can create multi-threaded and multi-process programs.
42. What is the need of tree shaking?
In every application, tree shaking may dramatically reduce code size. In other words, the less code we transmit over the wire, the more performant the programme. For example, if we only want to develop a "Hello World" application utilising SPA frameworks, it will take a few MBs, but tree shaking can reduce the size to a few hundred KBs. Tree shaking is supported by the Rollup and Webpack bundlers.
43. What are the two types of loops in javascript?
Entry Controlled Loops: The test condition is tested before entering the loop body in this sort of loop. This category includes For Loop and While Loop, for example. Exit Controlled Loops: The test condition is tested or assessed at the end of the loop body in this sort of loop. i.e., regardless of whether the test condition is true or not, the loop body will run at least once. This category includes, for example, the do-while loop.
44. What are the problems with post message target origin as a wildcard?
The postMessage method's second argument defines which origin is permitted to receive the message. If you provide the wildcard "*" as a parameter, the message can come from any origin. When sending the message, the sender window has no means of knowing if the target window is at the intended origin. If the target window was browsed to another origin, the data would be sent to that origin. As a result, XSS vulnerabilities may arise.
45. Return true if an integer n is a power of four. Return false otherwise. If there exists an integer x such that n == 4^x, then n is a power of four.
Example 1:
- Input: n = 16
- Output: true
Example 2:
- Input: n = 5
- Output: false
Example 3:
- Input: n = 1
- Output: true
To answer this question, use the "Power of 2" formula. Idea: If a number is a power of 4, it must also be a power of 2, but the opposite is not true. For example, 64 is both a power of 4 and a power of 2. However, 128 is just a power of two, not a power of four. So the game is solely about identifying the power of four. Let's look at some examples to see how they vary. n = 64: (64+1) per cent 3!= 0 "It is a power of two." n = 128: It is a power of two as well, but (128+1) per cent "== 0. " It is not a multiple of four." As a result, if n is a power of 2 and n+1 is not divisible by 3, then n is a power of 4.
bool isPowerOfFour(int n) {
int val = n; //Storing in another variable
//as value of n may change
if(n <= 0)
return false;
if((n & (n-1)) == 0) //Checking if it is a power of 2
{
if( (val+1) % 3 != 0) //If given_number + 1 is not divisilbe by 3
return true; //then it is our ans or power of 4
}
return false;
}
46. Return an array containing the intersection of two integer arrays nums1 and nums2. Each element in the result must be distinct, and the result may be returned in any order.
Example 1:
- Input: nums1 = [1,2,2,1], nums2 = [2,2]
- Output: [2]
Example 2:
- Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
- Output: [9,4]
- Explanation: [4,9] is also accepted.
In constant time, we utilise a hash table to keep track of all the unique components of a smaller array. Then, using the hash table, explore the larger list to discover the unique entries.
class Solution {
public:
// TC: O(M + N), SC: O(min(M, N))
// Using Hashing
vector<int> hashingSol(vector<int>& nums1, vector<int>& nums2) {
vector<int> result;
// find the smaller array to create a hash table
vector<int> *smaller = nums1.size() < nums2.size() ? &nums1 : &nums2;
vector<int> *bigger = nums1.size() > nums2.size() ? &nums1 : &nums2;
unordered_set<int> elements(smaller->begin(), smaller->end());
// Now in the bigger array, check each element if it belongs to the other array
// using the hash table
for(const int& num: *bigger)
if(elements.count(num)) {
result.emplace_back(num);
// remove the current element from hash table
elements.erase(num);
}
return result;
}
vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
return hashingSol(nums1, nums2);
}
};
47. Return an array containing the intersection of two integer arrays nums1 and nums2. Each element in the result must appear as many times as it appears in both arrays, and the result can be returned in any order.
Example 1:
- Input: nums1 = [1,2,2,1], nums2 = [2,2]
- Output: [2,2]
Example 2:
- Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]
- Output: [4,9]
- Explanation: [9,4] is also accepted.
We're making a nums1 frequency map. Then we go through nums2 and see whether any of its items are present in nums1. If so, we reduce the frequency count of that element in the map and include it in the final response.
class Solution {
public:
vector<int> intersect(vector<int>& nums1, vector<int>& nums2) {
unordered_map<int,int>M;
for(int i=0;i<nums1.size();i++)
{
M[nums1[i]]++;
}
vector<int>ans;
for(int i=0;i<nums2.size();i++)
{
auto itr=M.find(nums2[i]);
if(itr!=M.end() && itr->second != 0){
ans.push_back(nums2[i]);
itr->second--;
}
}
return ans;
}
};
48. Write a function that returns True if num is a perfect square and False otherwise given a positive integer num. Following that, avoid using any built-in library functions such as sqrt.
Example 1:
- Input: num = 16
- Output: true
Example 2:
- Input: num = 14
- Output: false
This solution takes advantage of the fact that all square numbers are the sum of odd integers beginning with 1.
As an example:
1 = 1
1+3 = 4
1 + 3 + 5 = 9
1 + 3 + 5 + 7 = 16
So, starting with 1, we remove odd numbers from the supplied number. When the number approaches zero, it is a perfect square. It is not a perfect square if it approaches a negative value without reaching zero.
class Solution {
public:
bool isPerfectSquare(int num) {
int i = 1;
while(num>0)
{
num -= i;
i += 2;
if(num==0)
{
return true;
}
}
return false;
}
};
49. Return true if ransomNote can be generated using the letters from magazine, and false otherwise, given two strings ransomNote and magazine. In ransomNote, each letter in the magazine may only be used once.
Example 1:
- Input: ransomNote = "a", magazine = "b"
- Output: false
Example 2:
- Input: ransomNote = "aa", magazine = "ab"
- Output: false
Example 3:
- Input: ransomNote = "aa", magazine = "aab"
- Output: true
If the size of ransomNote exceeds the size of magazine, return false. Else In two separate unordered maps, store all of the ransomNote and magazaine characters, as well as their related frequencies. If the frequency of a character in m ran is larger than the frequency in m mag, return false; otherwise, return true.
class Solution {
public:
bool canConstruct(string ransomNote, string magazine)
{
if(ransomNote.size()>magazine.size()) return false;
unordered_map<char,int>m_ran;
unordered_map<char,int>m_mag;
for(auto i:ransomNote)
m_ran[i]++;
for(auto i:magazine)
m_mag[i]++;
for(int i=0;i<ransomNote.size();i++)
{
if(m_ran[ransomNote[i]]>m_mag[ransomNote[i]])
return false;
}
return true;
}
};
Additional Resources
- https://www.interviewbit.com/technical-interview-questions/
- https://www.interviewbit.com/coding-interview-questions/
- https://www.interviewbit.com/software-engineering-interview-questions/
- https://www.interviewbit.com/azure-data-factory-interview-questions/
- https://www.interviewbit.com/blog/
- https://www.interviewbit.com/mock-interview/
- https://www.scaler.com/career-plan/
Optum Interview Preparation
1. Interview Preparation Tips
- Ask Question: Before you try to solve any coding or system design problem, you should always start by getting all the information you need about the problem. Again, interviewers often ask questions that aren't clear on purpose to see what kind of questions you'll ask to figure out what's going on. So make sure you ask any and all questions you deem relevant.
- Think Loud: Show your interviewer how your thinking works as you start to code or design your system. Explain why you're going in a certain direction or making the decisions you're making so that your interviewer can either understand how you make decisions or point you in the right direction.
- Communications: Interviewers will often let you know if they don't think you're going in the right direction. Listen carefully for feedback that might help you answer the question in the best way possible. If you don't pay attention to what people tell you, it could hurt you in an interview.
- Write clean code: Make sure your design and code are clean, clear, and easy to understand. This could mean putting your whiteboard in order, writing down the names of your variables, and so on.
- Learn DSA: Prepare for questions about the most common data structures and algorithms, as these are more likely to come up in your interview.
- Learn about new technologies: Recruiters at Optum often look for candidates who can think on the same scale or who know how to scale systems using the best technologies.
- Read about the company: Before your first interview, understand everything you can about UnitedHealth Group, the goal, the lines of business, the locations in which they do business, and the health sector in general. The more you learn about the company, the more comfortable you'll feel asking questions.
- Clear your doubts: Ask and answer simple questions about your ambitions prior to the interview. What do I intend to do? What motivates me to do it? What should my remuneration be? How can I persuade someone that my previous experiences have prepared me for the job?
- Preparation for the interview: Prepare the night before. Your interview attire, portfolio, and resume copies should all be prepared. Before the interview, get a good night's sleep and re-read your résumé.
- Be on time: Allow time for travel and aim to arrive ten to fifteen minutes early to prevent traffic or other delays. Before going, write down the meeting location and time, and inquire about parking availability.
- Be confident: Throughout the interview, smile and shake hands forcefully, and reflect your energy and excitement. Listen closely, keep your comments brief, and make eye contact with the recruiting manager. Ask the interviewer to characterize the job and tasks early in the discussion so you may focus your replies on your history, abilities, and accomplishments that are relevant to the position.
- Show interest: Make no disparaging remarks about current or past employment. During the initial interview, do not question pay, holidays, perks, or bonuses. If the interviewer asks what compensation you're looking for, provide a range based on your job market study, but emphasize you're more interested in the chance for continuous learning and professional growth.
- Take a follow-up step: Write down your thoughts and feelings as quickly as possible. Later, go through what you wrote and evaluate how well you performed. Write a follow-up thank-you note in which you remind the interviewer(s) of why your history and experiences qualify you for the position.
Frequently Asked Questions
1. Why do you want to work at Optum?
In terms of working for an organization, UHG is right up there with the best of them. This is an employee-friendly environment with a lot of activities to improve employees' technical and soft abilities. You will get the opportunity to work with cutting-edge technology as they modernize outdated tech stacks. It is a good place to start a career. You will be working on a variety of new projects. It will also give you the ability to have complete ownership of the product that you are delivering.
2. What is the salary for freshers in Optum?
The average compensation for an Optum Software Engineer in India is 9.9 Lakhs for those with less than one to six years of experience. At Optum, the compensation range for the position of Software Engineer is between 6 and 15 Lakhs.
3. How long is the Interview Process at Optum?
The duration of the Optum interview procedure might range from three weeks to three months. The level of the position, everyone's schedule, and other variables all influence the timetable.