C++ | 2 Ways | Brute Force vs Optimal
\n/*\n\tBrute Force\n*/\nint findLengthOfLCIS(vector<int>& nums) {\n\tint ans = 1;\n\tint i = 0;\n\twhile(i < nums.size()) {\n\t\tint m = 1;\n\t\tfor (int j = i
```\n/*\n\tBrute Force\n*/\nint findLengthOfLCIS(vector<int>& nums) {\n\tint ans = 1;\n\tint i = 0;\n\twhile(i < nums.size()) {\n\t\tint m = 1;\n\t\tfor (int j = i + 1; j < nums.size(); ++j) {\n\t\t\tif (nums[j] > nums[j - 1]) {\n\t\t\t\tm++;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tans = max(ans, m);\n\t\ti += m;\n\t}\n\treturn ans;\n}\n\n/*\n\tOptimal\n*/\nint findLengthOfLCIS(vector<int>& nums) {\n\tint ans = 1;\n\tint count = 1;\n\tfor (int i = 1; i < nums.size(); ++i) {\n\t\tif (nums[i] > nums[i - 1]) {\n\t\t\tcount++;\n\t\t\tans = max(ans, count);\n\t\t} else {\n\t\t\tcount = 1;\n\t\t}\n\t}\n\treturn ans;\n}\n```
['C']