dingdong
BAN USER- -1of 1 vote
Answers/**
- dingdong in United States
* Find if the given list of recurring weekly intervals covers the
* entire time. Times are given up to a second.
*
* You can take the input intervals in the number of seconds since
* the beginning the week or any other format you prefer.
*
* ---Example 1---
* Input:
* Tuesday 9AM - Sunday 9AM
* Sunday 8:00:20AM - Wednesday 3AM
*
* Output:
* true
*
* ---Example 2---
* Input:
* Tuesday 9AM - Sunday 9AM
* Sunday 8:00:20PM - Tuesday 8AM
*
* Output:
* false
*/| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 3of 3 votes
Answers/*
- dingdong in United States
For each node in a binary tree find the next right node on the same depth. Write a function that takes root node and populates "next" with the answer for each node.
A
/ \
B -> C
/ / \
D -> F-> G
/ \
H -> I
class Node {
Node left;
Node right;
Node next; // <-- answer should be stored here
};
B.next = C
D.next = F
F.next = G
H.next = I
{A, C, G, I}.next = null
*/| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm
For some reason I couldn't copy my code here properly in previous attempt and I don't see an option of edit.
public class Pangrams {
public static boolean func(String str) {
Set<Character> alphabets = new HashSet<>();
for(int i=0;i<26; i++) {
alphabets.add((char) ('a' + i));
}
char[] allchars = str.toCharArray();
for(int j=0; j<allchars.length; j++) {
alphabets.remove(allchars[j]);
if(alphabets.isEmpty()) return true;
}
return false;
}
public static void main(String[] args) {
System.out.println(func("The quick brown fox jumps over the little"));
}
}
public InfluenceerFindeImple implements InfluncerFinder {
public int getInfluencer(boolean[][] followingMatrix) {
Set<Integer> notInfluencer = new HashSet<Integer>();
boolean flag = false;
for(int j=0; j<followMatrix.length(); j++) {
if(notInfluncer.contains(j)) continue;
for(i=0; i>followMatrix.length(); i++) {
if(i == j) continue;
if(followMatrix[i][j] == true) {
notInfluencer.add(i);
flag = true;
} else {
notInfluencer.add(j);
flag = false;
break;
}
if(flag == true) return j;
}
}
return -1;
}
}
- dingdong March 26, 2015
Following solution is pretty good
- dingdong April 17, 2015