unknown Interview Report
- 0of 0 votes
AnswersYour friend has invented a new compound consisting of N elements. However, he has forgotten the amount of each element that goes into the recipe.
- Abhishek.Mathur.CA September 30, 2016 in United States
For N-1 pairs of elements, he remembers the proportion in which the elements within each pair should be added to the compound. Fortunately, these N-1 proportions are sufficient to restore the recipe of the entire compound.
You are given N-1 proportions as String. Each String is formatted "#<a> and #<b> as <p>:<q>" (quotes for clarity), which means that the mass of element <a> divided by the mass of element <b> in the cocktail must be equal to <p>/<q> (all elements are 0-indexed). Print exactly N elements, where the first line is the mass of element 0 and second line is the mass of element 1 and so on... such that all the given proportions are satisfied and the total mass is as small as possible. The total mass must be greater than 0.
Input
Line 1: N
Line 2 .. N: proportion_i
Output
N lines of masses, as stated in the problem statement
Input Explanation
Line 1: N, the number of elements
Line 2 to line N: N-1 proportions, format described in the problem statement
Output Explanation
Output will contain exactly N lines, each line is the mass of the element such that all the given proportions are satisfied and the total mass is as small as possible. The total mass must be greater than 0.
Sample Input
3
#0 and #1 as 9:8
#1 and #2 as 9:8
Sample Output
81
72
64| Report Duplicate | Flag | PURGE
unknown Software Developer - 0of 0 votes
AnswersConsider a social website SocialX, where friends connect to each other, just as they do on Facebook
- Abhishek.Mathur.CA September 30, 2016 in United States
Friendship on SocialX is symmetric (if X is a friend of Z, then Z is also a friend of X) however not transient (if X and Z are friends and Z and Y are friends, then X and Y are not necessarily friends)
The term "k-joined" is defined as follows. If two people are friends, they are called 1-joined. For k >= 1, two people X and Z are called (k+1)-joined if X and Z are k-joined, or if there exists a person Y such that X and Y are k-joined and Y and Z are friends.
"Approachable Score" is defined as follows. If two people X and Z are not friends, then their Approachable Score is the fewest number of people (other than themselves) who must be removed from the network in order for X and Z to not be 3-joined. The higher the Approachable Score, the more likely it is that X and Z know each other.
Given a set of friends containing exactly K elements, where K is the number of people in the network. People are numbered from 0 to K-1. The j-th character of the i-th element of friends is '1' if i and j are friends, and '0' otherwise. Return the Approachable Score for personX and personZ
Constraints
Set of friends will contain exactly K (1 < K < 41) elements, where each element will contain exactly K characters. Each character will either be '0' or '1'
friends[i][j] will always be equal to friends[j][i] and friends[i][i] will always be equal to 0
friend[personX][personZ] will be equal to 0 and personX will never be equal to personZ
Input Format
Line 1: comma separated K elements representing friends
Line 2: Integer representing personX
Line 3: Integer representing personZ
Output Format
Integer representing Approachable Score
Sample Input
0100,1010,0101,0010
0
3
Sample Output
1
Explanation
Either remove person 1 or person 2 to get an Approachable Score of 1 for person 0 and 3| Report Duplicate | Flag | PURGE
unknown Software Developer