Hitesh Vaghani
BAN USERUse mongoDB and it'll be quite simple. It's kind of tricky one. First you should ask about database not the number of hotels.
- Hitesh Vaghani June 22, 2015I just written what's popped in my mind first. Hadn't checked it. I'll check it.
- Hitesh Vaghani October 16, 2014Try to convert spiral matrix into counter spiral...that would be far easy and fun learning.
// For 4 X 4 Matrix
int m = 4, n = 0, k = 0, l = 4, i;
/* k - starting row index
m - ending row index
l - starting column index
n - ending column index
i - iterator
*/
while(k < m && l > n)
{
for(i = l-1; i >= n; i--)
cout<<a[k][i]<<" ";
k++;
for(i = k; i < l; i++)
cout<<a[i][n]<<" ";
n++;
if(k < m)
{
for(i = n; i < l; i++)
cout<<a[m-1][i]<<" ";
m--;
}
if (l > n)
{
for (i = m-1; i >= k; --i)
{
cout<<a[i][l-1]<< " ";
}
l--;
}
}
yes, we can do so.i have no idea when to use which one..
but i can find after how many cycle/s both will meet..
take one count variable...increment it after every comparison of pointer that we used for checking circular link list.
something like this ,
if(pointer are same)
circular link list
else
count++;
we will get count..by using that count we will get cycle count..
cycle_count = count % multiplier_factor(2x,3x)...
Trace it out..
For example if circular link list having 14 node and we use multiplier_factor of 3...
we will get answer in 2nd cycle
1->2->3->4->5->6->7->8->9->10->11->12->13->14->1(just for sake i show you ->1 in last).
Multiplier Factor is 3x
1->4->7->10->13->2->5->8->11->14
[------cycle one-----][-------cycle two----]
@coderBaba Thank you..
- Hitesh Vaghani September 10, 2012There is no loops my friend . i an just calling constructor 1000 times..
Thanks Mukesh and Abhey.
Thank you..
- Hitesh Vaghani September 08, 2012We can use heterogeneous data type..
- Hitesh Vaghani September 08, 2012We can use class.. No recursion, No loops..
class Print
{
public:
Print()
{
static int count = 0;
cout<<"h"<<++count<<endl;
}
};
int main()
{
Print print[1000];
getchar();
return 0;
}
so, ultimate solution is 4.. we have to give best solution for worst case in problem solving..
- Hitesh Vaghani September 06, 2012If you don't want to use 2 pointers.. you can use array to store all values like
while(! node->next)
{
a[i++] = node->deata;
node = node->next;
count++;
}
cout << "moddle one is " << a[count/2];
I know about c++...Implicit functions in c++ are Template, Destructor, Void pointer etc..but i am not sure about that..
- Hitesh Vaghani September 05, 2012we can get answer in 4 steps...
- Hitesh Vaghani September 05, 2012
Intersection of their dates.
- Hitesh Vaghani June 22, 2015