Anon
BAN USER- 0of 0 votes
Answerspublic interface Permutations {
- Anon in United States
/**
* Generate all permutations of given sequence of elements.
* Return a list of all distinct permutations.
*
* E.g.
* generate([1, 2, 3]) -> [1, 2, 3], [1, 3, 2], [2, 3, 1], [2, 1, 3], [3, 1, 2], [3, 2, 1]
*/
vector<vector<int>> generate(vector<int> items);
}| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Coding - 0of 0 votes
Answerspublic interface InfluencerFinder {
- Anon in United States
/**
* Given a matrix of following between N LinkedIn users (with ids from 0 to N-1):
* followingMatrix[i][j] == true iff user i is following user j
* thus followingMatrix[i][j] doesn't imply followingMatrix[j][i].
* Let's also agree that followingMatrix[i][i] == false
*
* Influencer is a user who is:
* - followed by everyone else and
* - not following anyone himself
*
* This method should find an Influencer by a given matrix of following,
* or return -1 if there is no Influencer in this group.
*/
int getInfluencer(boolean[][] followingMatrix)| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Arrays