Sunday, 15 September 2019

Circles Life Interview Experience

Circles Life Singapore Interview Experience


Circles Life Singapore


Round1 - Online Coding Assessment
Q1 Employees Per Department
A company uses 2 data tables, Employee and Department, to store data about its employees and departments.

Table Name: Employee
Attributes:
ID Integer,
NAME String,
SALARY Integer,
DEPT_ID Integer

Table Name: Department
Attributes:
DEPT_ID Integer,
Name String,
LOCATION String

Write a query to print the respective Department Name and number of employees for all departments in the Department table (even unstaffed ones).

Sort your result in descending order of employees per department; if two or more departments have the same number of employees, then sort those departments alphabetically by Department Name.

Solution

Q2 Maximum Difference in an Array
Given an array arr[] of integers, find out the maximum difference between any two elements such that larger element appears after the smaller number.
In other words, for the array arr, find the maximum value of arr[j] - arr[i] such that 0<=iIf no item has a smaller item with a lower index then return -1

Sample Case
Input
7
2 3 10 2 4 8 1

Output: 8
Explanation
3 - [2] = 1
10 - [3, 2] = [7, 8]
4 - [2, 3, 2] = [2, 1, 2]
8 - [4, 2, 3, 2] = [4, 6, 5, 6]

Thus the maximum is found at 10-2 = 8

Solution

Q3 Steps to convert binary number to zero
Given a decimal number, how many minimum possible steps are required to convert this to zero provided:

  • Change the bit i if the next bit i+1 is '1' and rest all the other bits i+2 and later is 0
  • Change the last bit without restriction
Solution


Round2 - Coding and Problem Solving
Q1 Print all the maximum elements from the right?
Example
Input: { 10, 4, 6, 3, 5 }
Output: { 10, 6, 5 }

Solution

Q2 Print all the zero sum triplet in a given array.
Example
Input: {4, 0, -1, -3, -9, -4, 2 , 1}
Output: [[a = -4, b = 0, c = 4], [a = -3, b = -1, c = 4], [a = -1, b = 0, c = 1]]

Solution

Q3 Print first non recurring character in a given array.
Example
Input: {'d', 'g', 'h', 'w', 'i', 'g', 'd', 'w', 'o'}
Output: h

Solution

No comments :

Post a Comment