Even if its collapsing into almost a straight line, the structure is still
a tree with a node having a maximum of 3 nodes, thus can be called a
ternary tree.
--
Thanks and Regards,
Amol Sharma
On Mon, Jan 20, 2014 at 10:50 PM, Don dondod...@gmail.com wrote:
Good point, Vikas.
What if the
i din't get ur question.
isn't the equation *(x - 7) + 7 = (x + 1) - 5* invalid ?
--
Thanks and Regards,
Amol Sharma
On Wed, Jan 15, 2014 at 3:34 AM, Arpit Sood soodfi...@gmail.com wrote:
Equivalent to solving an infix expression using stack with a pair (first
variable, second constant)
Given an array of positive numbers arranged in any order. You have to find
the length of longest continuos(difference of +1, -1) sequence in the array.
for eg.
A[] = *5*, 20, 45, *3*, 98, *4*, 21, *1*, 99, *2*
then longest continuos subsequence is [1, 2, 3, 4, 5] and hence the output
should be
^ No its not invalid. It just represents an equation with infinitely many
correct solutions depending on the domain of x.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Mon, Jan 27, 2014 at 4:21 PM, Amol Sharma amolsharm...@gmail.com wrote:
i din't get
I think this the most optimized code i have writen :
#include iostream
#include vector
#include map
using namespace std;
int longest_sequence(vectorint nums) {
mapint,bool mp;
int count;
int max = -;
int n = 0;
for(unsigned int i = 0; i nums.size(); i++) {
mp[nums[i]] = true;
This works, and I think is O(N*log(N)) which is similar to sorting and
scanning.
An unordered map will be faster, in general. It could be made faster in
most cases by looping over items left in the map, to avoid processing the
same number more than once. Also, when the number of items left in
Ws
On 27 Jan 2014 17:02, saurabh singh saurab...@gmail.com wrote:
^ No its not invalid. It just represents an equation with infinitely many
correct solutions depending on the domain of x.
Saurabh Singh
B.Tech (Computer Science)
MNNIT
blog:geekinessthecoolway.blogspot.com
On Mon, Jan 27,