Arian
BAN USER- 3 Answers Being rejected though I correctly solving the problems
Hi guys ,
- Arian October 13, 2013
Recently I've had 3 in-person interviews (2 of them small companies and 1 a bigger one) , I was rejected in the two small ones and got accepted by the larger one.
I have a visa issue which I need to wait for 1 year to start my job (in the states) and I do the coding in Java. The two smaller companies did know that I do programming in Java but they used C# and Microsoft stack generally.
One of the smaller companies was not sure that I have visa issue but at the end of the interview day they told me that they can provide visa sponsorship.
I answered all the questions correctly as they all told me that I did a nice job ! but some days after I got rejected. I had a very nice attitude and we got friends at the interview but I can't understand why they rejected me ! It was really disappointing as you think you will be definitely offered a job but it doesn't happen !
Any idea ? How do they decide ? may it be because of visa problem ? may it be because I do the coding in Java and they use Microsoft stack ?
I'm confused :(| Flag | PURGE
First find the path (starting from root) for the first node , then the same for the second node. Then find the lowest common ancestor and the number of nodes in the requested path.
ArrayList<Node> find_path(Node current , Node n, ArrayList<Node> path){
path.add(current);
if (current == n)
return path;
if (current.left != null){
ArrayList<Node> p1 = find_path(current.left , n , path);
if (p1 != null)
return p1;
}
if (current.right != null){
ArrayList<Node> p2 = find_path(current.right , n , path);
if (p2 != null)
return p2;
}
path.remove(path.remove(path.size() - 1));
return path;
}
int find_path_nodes(Node root , Node n1 , Node n2){
ArrayList<Node> p1 = find_path(root , n1 , new ArrayList<Node>());
ArrayList<Node> p2 = find_path(root , n2 , new ArrayList<Node>());
int i = 0;
for (; i < Math.min(p1.size() , p2.size()) ; i++){
if (p1.get(i) != p2.get(i))
break;
}
return p1.size() + p2.size() - 2 * i + 1;
}
Update :
The time has to be changed to : C(n, ceil(n/2))!
I guess it would be :
C( C(n , ceil(n/2)) , n) //this is wrong , look at the update
Because for each line in the matrix you can choose n/2 out of n places for FALSE values and you have 'n' lines of matrix.
static ArrayList<Boolean[]> lines = new ArrayList<Boolean[]>();
static void matrix_choice(int n){
Boolean[] line = new Boolean[n];
for (int i = 0 ; i < line.length ; i++)
line[i] = true;
choice_make_line((int)Math.ceil((double)n/2) , line , 0 , 0);
Boolean[][] matrix = new Boolean[n][n];
for (int i = 0 ; i < n ; i++)
for (int j = 0 ; j < n ; j++)
matrix[i][j] = true;
choice_make_matrix(matrix , 0 , 0);
}
static void choice_make_matrix(Boolean[][] matrix , int array_index , int line_index){
if (line_index == matrix.length){
for (int i = 0 ; i < matrix.length;i++)
System.out.println(Arrays.toString(matrix[i]));
System.out.println("------------------------------------------------------------------");
}
if (array_index == lines.size())
return;
matrix[line_index] = lines.get(array_index);
choice_make_matrix(matrix , array_index+1 , line_index+1);
choice_make_matrix(matrix , array_index+1 , line_index);
}
static void choice_make_line(int m , Boolean[] line , int index, int chosen_so_far){
if (chosen_so_far == m){
lines.add(line.clone());
return;
}
if (line.length - index < m - chosen_so_far)
return;
line[index] = false;
choice_make_line(m , line , index + 1, chosen_so_far+1);
line[index] = true;
choice_make_line(m , line , index + 1, chosen_so_far);
return;
}
It's simple mathematics , You can solve it in O(1):
int number_of_nodes(int k ){
int result = 0;
if (k % 2 == 0){
result = (Math.pow(12 , k/2 - 1) - 1) / 11 + 3 * ( Math.pow(12, (k-1)/2) -1) /11 ;
}else{
result = (Math.pow(12,(k-1)/2) - 1) / 11 + 3 * (Math.pow(12,(k-1)/2 - 1 ) - 1 )/ 11;
}
}
void find_sum(int[] arr , int sum){
Arrays.sort(arr);
int left = 0;
int right = arr.length - 1;
while (left < right){
if (arr[left] + arr[right] > sum)
right--;
else if (arr[left] + arr[right] < sum)
left++;
else{
System.out.println(arr[left] + " : " + arr[right]);
return;
}
}
}
If the user is signed in , the algorithm can use the profile information of the user to return better search results , for example if the user regularly
searches about the computer science concepts, then algorithm can use this information to return results of the related field when there's an ambiguity in the search keywords , for example
if the user is searching for tree , the algorithm may assign more weights to the TREE datastructure.
If the user clicks on the k-th result the algorithm can reduce the relevancy of the the previous k-1 results.
If the user returns back to the search engine within a certain time frame and uses the same keywords it means that he/she is not satisfied with the past results , so the relevancy of the past results can be decreased.
The algorithm can also use soundex , stemming & translation algorithms to create larger number of results (this increases the False Positive).
The algorithm can also use the context of the keywords to guess what user is really looking for. (For this task, Natural Language Processing and Machine Learning Techniques may be useful)
As you said , you are sending all of the urls on the network , which I guess is impossible as it's been said in the question. It works but it doesn't conform to the constraints.
- Arian October 15, 2013