Megha Maheshwari
BAN USER
- 0of 0 votes
AnswersWrite a code to find out the median in an array of integers (array could have even number of elements or odd number of elements)
- Megha Maheshwari in United States
(To update some hint at the end from the interviewer : he would look for a binary tree and find out some way to balance the tree and than obtain the median)| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
AnswersGiven employee information in an organisation in the formal - emp_id,firstname,lastname,reports_to in the following way
- Megha Maheshwari in Singapore
{
string[] Values = new[] { "Mc Grill,Mc,Grill,Karmon","Karmon,Zech,Karmon,Joe","Mithun,Try,Mithun,Joe","Joe,Top,Joe,","Zara,Aman,Zara,Mc Grill","Fizzy,Dude,Fizzy,Mc Grill"};
}
Print the information from the top to bottom level in the way
1) Top Joe
2) Try Mithun
2) Zech Karmon
3) Mc Grill
4)Aman Zara
4) Dude Fizzy| Report Duplicate | Flag | PURGE
Amazon
1 Answer Reverse an array of integers
Is there a better way to reverse an array of integers than the one below. Will using a stack perform better
- Megha Maheshwari November 18, 2015
int [] array = {2,5,7,8,9,10}
int startindex = 0;
int endindex = array.Length -1;
while(startindex < endindex)
{
int temp = array[startindex];
array[startindex] = array[endindex];
array[emdindex] = temp;
startindex++;
endindx--
}
Complexity : O(n/2)| Flag | PURGE
i think for your first code, the comment should be // even number of elements instead of odd
- Megha Maheshwari December 09, 2015is st.elementAt some kind of an inbuilt function. This looks like we are not accessing the top element always. Os this a good idea to do when we have to take care of the properties of stack?
- Megha Maheshwari December 08, 2015What would exactly be the complexity of this. I am assuming it would be the length of the string since you need that many push and pop
- Megha Maheshwari December 08, 2015Data structures and how to determine the runtime of your code...Usually they will ask you to write a code and than ask you about the runtime of the code
- Megha Maheshwari November 18, 2015
Repdubinalinda4, Animator at Apache Design
Hello, I am a school librarian from Lewistown USA. I work in public or private schools at elementary, middle and ...
- Megha Maheshwari May 24, 2017