DFG Back-End Engineer Hiring Test With Answers
DFG Back-End Engineer Hiring Test With Answers
DFG Back-End Engineer Hiring Test With Answers
Sample Case 0
Sample Input 0
4
4
13
2
3
Sample Output 0
Explanation 0
tickets = [4, 13, 2, 3]
There are two subsequences of tickets that contain consecutive Help
integers: {2, 3, 4} and {13}. These subsequences have m values of 3
1/10
and 1, respectively. Return the maximum value of m, which is 3.
12/11/2019 DFG Back-End Engineer Hiring Test | Programming problems and challenges | HackerRank
Start with an initial guess for x, an integer, and a given array of
integers. Calculate a running sum of x plus each array element, from
left to right. The running sum must never get below 1. Given an array
of integers, determine the minimum value of x.
For example, arr = [-2, 3, 1, -5]. If x = 4, the following results are
obtained:
Running
sum arr[i]
--------- --------
4 -2
2 3
5 1
6 -5
1
The final value is 1, and the running sum has never dropped below 1.
The minimum starting value for x is 4.
Function Description
Complete the function minX in the editor below. The function must
return the minimum integer value for x.
minX has the following parameter(s):
arr[arr[0],...arr[n-1]]: an array of integers
Constraints
1 ≤ n ≤ 105
−100 ≤ arr[i] ≤ 100
Sample Case 0
Sample Input 0
10
-5
4
-2
3
1
-1
2/10
-6
12/11/2019 -1 DFG Back-End Engineer Hiring Test | Programming problems and challenges | HackerRank
0
5
Sample Output 0
Explanation 0
Running
sum arr[i]
--------- --------
8 -5
3 4
7 -2
5 3
8 1
9 -1
8 -6
2 -1
1 0
1 5
6
Sample Case 1
Sample Input 1
5
-5
4
-2
3
1
Sample Output 1
Explanation 1
Running
sum arr[i]
--------- --------
6 -5
1 4
5 -2
3 3
6 1
7
Sample Case 2
Sample Input 2
10
-5
4
-2
3
1
3/10
-1
12/11/2019 -6 DFG Back-End Engineer Hiring Test | Programming problems and challenges | HackerRank
-1
0
-5
Sample Output 2
13
Explanation 2
Running
sum arr[i]
--------- --------
13 -5
8 4
12 -2
10 3
13 1
14 -1
13 -6
7 -1
6 0
6 -5
1
4/10
userId: the user id of the user who performed the transaction
12/11/2019 userName: the user name
DFG Back-End of theHiring
Engineer user who
Testperformed the problems and challenges | HackerRank
| Programming
transaction
txnType: the transaction type of the
transaction, either debit or credit
amount: the transaction amount stored as a string with the
currency structure and prefixed with the $ sign, e.g. "$2,273.95".
location: the object containing the location description of the
transaction
location.id: the id of the location where the transaction took
place
location.address: the address of the location where the
transaction took place
location.city: the city where the transaction took place
location.zipCode: the zip code of the location where the
transaction took place
ip: the IP address of the device which was used to perform the
transaction
Given the locationId, locationId, and the provided transaction type,
txnType, return a 2d array containing the total amount transacted by
each user at the given locationId.
The array will be in the format [ [1, 1200] , [2, 2333] ] where the item at
index 0 in the inner array denotes the id of the user and item at index 1
denotes the total amount transacted (either debit or credit based on
input txnType). The items in the outer array should be sorted by the ids
of the user. Note that the search is not case sensitive.
Function Description
Complete the function getTransactions in the editor below.
getTransactions has the following parameter(s):
int locationId: the id of the location by which record will be fetched,
to be matched with the property location.id
string txnType: the transaction type to filter the records on
Returns:
[int[]]: a 2d array containing the total amount transacted by each
user at the given location id. If no records are found matching the filter
criteria, it should return [[-1, -1]].
Note: The total amount should be rounded off to 2 places after the
decimal. It can also be returned as a string.
Sample Case 0
STDIN Function
----- --------
1 → locationId = 1
debit → txnType = 'debit'
Sample Output
5/10
1 13200.08
12/11/2019 2 DFG Back-End Engineer Hiring Test | Programming problems and challenges | HackerRank
16745.72
3 18859.77
4 10360.32
[
{ id: 1,
userId: 1,
userName: 'John Oliver',
timestamp: 1549536882071,
txnType: 'debit',
amount: '$1,670.57',
location: { id: 7,
address: '770, Deepends, Stockton Street',
city: 'Ripley',
zipCode: 44139
},
ip: '212.215.115.165'
}...
]
Given the response from the API for txnType = 'debit', filter the
records. After filtering the data to find all the records which belong
to location.id = 1, find the total amount spent by each user. The final
values for user 1 is 11590.28, for user 2 is 17410.38 and so on.
Finally create the 2d array containing the answer [[1, 13200.08], [2,
16745.72], [3, 18859.77], [4, 10360.32]] which is returned.
Both replication and partitioning can be crucial in improving the performance of delivering
data on request.
In leader-based replications, one of the nodes stores all the data. Only when needed, the
other nodes ask the leader to deliver data that they do not have.
Using hash-based partitioning usually has a disadvantage in the performance of range-
based queries
6/10
Medium Distributed Systems Distributed Message Queue
12/11/2019 DFG Back-End Engineer Hiring Test | Programming problems and challenges | HackerRank
Message queues, in general, decrease the overall performance of the system.
XML
JSON
CSV
None of these
7/10
Question - 8 SCORE: 5 points
12/11/2019 Restrictions
DFGofBack-End
RESTful web services
Engineer Hiring Test | Programming problems and challenges | HackerRank
Medium
There should be separate concerns for each server and client which will help to maintain
the modularity within the application. This will also reduce the complexity and increase
the scalability.
The client-server communication should be stateless, which means no previous
information is used and the complete execution is done in isolation. In cases of failure, it
also helps the client to recover.
In client-server communication, the HTTP response should be cacheable so that when
required, a cached copy can be used which in turn enhances the scalability and
performance of the server.
Client-server communication should be done on a layered system. Thus the client should
only have knowledge about the intermediate level with which communication is being
done.
Uniform interface
Stateless
Cacheable
Layered system
8/10
12/11/2019 After eachDFG Back-End
operation, Engineer
print Hiring
the value at theTest
top |ofProgramming problems and challenges | HackerRank
the stack. If the
stack is empty, print the string EMPTY. For example:
Function Description
Complete the superStack function in the editor below. After each
operation, print the value of the stack's top element on a new line. If
the stack is empty, print EMPTY instead.
superStack has the following parameter(s):
operations[operations[0],...operations[n-1]]: an array of strings
Constraints
1 ≤ n ≤ 2 × 105
-109 ≤ v ≤ 109
1 ≤ i ≤ |S|, where |S| is the size of the stack at the time of the
operation.
It is guaranteed that pop is never called on an empty stack.
Sample Case 0
Sample Input 0
12
push 4
pop
push 3
push 5
push 2
inc 3 1
pop
push 1
inc 2 2
push 4
pop
pop
Sample Output 0
4
EMPTY
3
5
2
3
6
9/10
1
12/11/2019 1 DFG Back-End Engineer Hiring Test | Programming problems and challenges | HackerRank
4
1
8
Explanation 0
The diagram below depicts the stack after each operation:
After performing each operation, print the value at the top of the
stack on a new line.
Start with an empty stack, S, expressed as an array where the lowest
indexed element is the bottom of the stack and the highest is its top.
Perform n = 12 operations as given:
1. push 4: Push 4 onto the stack, so S = [4]. Print the top (rightmost)
element, 4, on a new line.
2. pop: Pop the top element from top of the stack, so S = []. Print
EMPTY on a new line.
3. push 3: Push 3 onto the stack, S = [3]. Print 3, and the top of the
stack after each of the following operations.
4. push 5: Push 5 onto the stack, S = [3, 5].
5. push 2: Push 2 onto the stack, S = [3, 5, 2].
6. inc 3 1: Add v = 1 to the bottom i = 3 elements of the stack, S = [4,
6, 3].
7. pop: Pop the top element from the stack, S = [4, 6].
8. push 1: Push 1 onto the stack, S = [4, 6, 1].
9. inc 2 2: Add v = 2 to bottom i = 2 elements of the stack, S = [6, 8,
1].
10. push 4: Push 4 onto the stack, S = [6, 8, 1, 4].
11. pop: Pop the top element from the stack, S = [6, 8, 1].
12. pop: Pop the top element from the stack, S = [6, 8].
10/10