Skip to main content
added 2 characters in body
Source Link

Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i+1]>a[i]$$$$a[i+1] >a[i]$$.

Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i+1]>a[i]$$.

Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i+1] >a[i]$$.

added 231 characters in body
Source Link

For instance if the input is:

6
3 >
2 <
1 >
3 >
1 <
8 <

Then the output is 4 And the only maximum subsequence that we can choose is: 2 < 1 > 3 > 8 < because 1<2 3>1 and 8>3.

My idea: I tought about constructing the array dp[] such that dp[i] represents the maximum length of the longest sequence of (a[i],b[i]) with the given properties. I constructed it from the end like this:

My idea: I tought about constructing the array dp[] such that dp[i] represents the maximum length of the longest sequence of (a[i],b[i]) with the given properties. I constructed it from the end like this:

For instance if the input is:

6
3 >
2 <
1 >
3 >
1 <
8 <

Then the output is 4 And the only maximum subsequence that we can choose is: 2 < 1 > 3 > 8 < because 1<2 3>1 and 8>3.

My idea: I tought about constructing the array dp[] such that dp[i] represents the maximum length of the longest sequence of (a[i],b[i]) with the given properties. I constructed it from the end like this:

added 40 characters in body
Source Link

Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the sequencesubsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i+1]>a[i]$$.

Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the sequence (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i+1]>a[i]$$.

Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i+1]>a[i]$$.

Source Link
Loading