Tip 1 : work on communication skills
Tip 2 : Data Structures and Algorithums
Tip 1 : Include al teast two good project
Tip 2 : good to mention your skills
How to Design BookMyShow, Fandango (or similar movie ticketing application)
A movie ticket booking application such as BookMyShow facilitates users to browse through movies and live events, watch trailers, check seat availability and purchase a ticket. Let’s discuss how to design a similar online ticketing system
bool isAnagram(string s, string t) {
int a[256]={0};
for(int i=0;i {
a[s[i]]++;
}
for(int i=0;i {
a[t[i]]--;
}
for(int i=0;i<256;i++)
if(a[i]!=0)
return false;
return true;
}
int findPeakElement(vector& nums) {
int max=-2147483648;
int pos=0;
for(int i=0;imax)
{
max=nums[i];
pos=i;
}
}
return pos;
}
The diameter of a binary tree is the length of the longest ...
int height(TreeNode* root,int *x)
{
int lh=0;
int rh=0;
int ld=0;
int rd=0;
if(root==NULL)
return 0;
ld=height(root->left,&lh);
rd=height(root->right,&rh);
*x=max(lh,rh)+1;
return max(lh+rh+1,max(ld,rd));
}
int diameterOfBinaryTree(TreeNode* root) {
int x=0;
return height(root,&x)-1;
}
Make a fair coin from a biased coin
You are given a function foo() that represents a biased coin. When foo() is called, it returns 0 with 60% probability, and 1 with 40% probability. Write a new function that returns 0 and 1 with a 50% probability each. Your function should use only foo(), no other library method.
We know foo() returns 0 with 60% probability. How can we ensure that 0 and 1 are returned with a 50% probability?
The solution is similar to this post. If we can somehow get two cases with equal probability, then we are done. We call foo() two times. Both calls will return 0 with a 60% probability. So the two pairs (0, 1) and (1, 0) will be generated with equal probability from two cal...