Interview Questions 3/23/2020
IMPORTANT: DO NOT search the answer online or ask somebody else to help you
1. Given the following pseudocode, enumerate the possible causes of the error encountered by the
user:
function isUserActive(UserObject user) {
return checkActiveStatus([Link]().trim())
}
function checkActiveStatus(string username) {
try {
rows = getDatabaseRowsOnActiveTableForUser(username)
} catch (Exception e) {
throw DatabaseException
}
return [Link]().getColumnValue("IsActive")
}
The function getDatabaseRowsOnActiveTableForUser is not defined here.
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 1 of 8
Interview Questions 3/23/2020
2. Write a simple console application that prints the numbers from 1 to 200, except
For numbers that are multiples of five print 'Foo'
For numbers that are multiples of seven print 'Bar'
For numbers that are multiples of both five and seven print 'FooBar'
using [Link];
using System;
class Program
{
static void Main(string[] args)
{
[Link] = 102;
for (int i = 1; i <= 100; i=i+1)
{
if((i%5)==0&&(i%7)>1)
{
[Link]("Foo");
}
else if((i%7)==0&&(i%5)>1)
{
[Link]("Bar");
}
else if((i%7)==0&&(i%5)==0)
{
[Link]("FooBar");
}
else
{
[Link](i);
}
[Link]();
}
}
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 2 of 8
Interview Questions 3/23/2020
3. Question: Given the following function PROCESS_STRING
Function PROCESS_STRING(S)
N = LENGTH (S)
If (N = 1) Then
Return S
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 3 of 8
Interview Questions 3/23/2020
Else
Return PROCESS_STRING (SUBSTRING(S,1,N-1)) + SUBSTRING
(S,0,1)
End If
Note –
LENGTH(S) is a function that returns the length of a string S
SUBSTRING(S, B, E) is a function that returns a sub-string of the string S, where B is the
beginning index (inclusive) of S and E is the end index (inclusive) of S.
Describe the execution and the output of the following invocation: PROCESS_STRING(“!@#$%^”)
It will create a never ending loop.
4. LINQ code writing: Complete the following method: use LINQ to retrieve the first row from
AppCategories giving the condition that AppTypeName starts with categoryName, which is passed to
this method and then order by the length of AppTypeName.
private AppType GetCategory(string categoryName)
{
var allCategoryItems = (List<AppType>) [Link];
AppType type = null;
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 4 of 8
Interview Questions 3/23/2020
//Add code here
return type;
}
5. Given a string, which contains numbers(‘1’ to ‘100’) and alphabets (‘a’ to ‘z’ and ‘A’ to ‘Z’),
please reverse the string in a way that numbers are not affected. (numbers should keep the
original position)
Input: str = "ab2cd5xyz"
Output: str = "zy2xd5cba"
Note that 2 and 5, are not moved anywhere.
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 5 of 8
Interview Questions 3/23/2020
Only subsequence "abcdxyz" is reversed
Input: str = "Hello10World”
Output: str = "dlroW10olleH"
Notes: A function ReverseStr(string input) is already available for you to call. This function is only able to
reverse a normal string. You can decide to use this existing function or not by yourself.
public string ReverseStr(String input)
{
char[] str = [Link]();
// Initialize left and right pointers
int r = [Link] - 1, l = 0;
// Traverse string from both ends until
// 'l' and 'r'
while (l < r)
{
// Ignore letter
if ()
l++;
else if()
r--;
// Both str[l] and str[r] are not letter
else
{
char tmp = str[l];
str[l] = str[r];
str[r] = tmp;
l++;
r--;
}
}
return new String(str);
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 6 of 8
Interview Questions 3/23/2020
6. SQL query test:
Device:
Device_Id Device_Name Device_Cost Location_Id
1 Device1 100 1
2 Device2 200 null
3 Device3 300 2
4 Device4 400 null
Asset:
Asset_Id Computer_Info Asset_Description Device_Id
1 A_Asset1 Good 1
2 B_Asset1 Ok 4
3 A_Asset2 Bad 2
4 B_Asset2 Good 1
5 A_Asset3 Bad 1
6 B_Asset3 Bad 3
7 A_Asset4 Bad 2
8 B_Asset4 Ok 3
Location:
Location_Id Location_Code Location_State Location_City
1 Code1 CT City1
2 Code2 OH City2
a. Write a query using above tables to retrieve “Device Name”, “Computer Info” and “Location
State” on the condition: “Computer_Info” starts with “A” or Location_State is CT or no location.
Select D.Device_Name, A.Computer_info ,L.Location_state
from Asset A inner join Device D on D.Device_id = A.Device_id
left join Location L on D.Location_Id = L.Location_id
Where A.Computer_info LIKE 'A%' OR L.Location_state = 'CT' OR D.Location_Id = NULL
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 7 of 8
Interview Questions 3/23/2020
b. if we purchase the device and assets together, write a query to get the most expensive device.
(the cost should include both device and assets)
7. Given a varchar string @testStr=’YYYINIYLJKYYLBNY’. Please write a SELECT statement to get the count
of all ‘Y’ in @testStr.
SELECT LEN(REPLACE(@testStr, 'Y', ''))
Confidential and Proprietary Information of OptumInsight, Inc.
For Internal use only
Page 8 of 8