The program is about LONGEST SUBSEQUENCE. I tried to give input until -1 is occurred but the output console is getting hanged after I enter -1. I tried running it on online compilers too...but still no solution.
Here is the output screenshot in VSCode
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { vector<int> v; unordered_set<int> s; int count, res = 0; cout << "Enter the elements of the array: "; while (1) { cin >> count; if (count == -1) break; v.push_back(count); s.insert(count); } for (int i = 0; i != v.size(); i++) { if (s.find(v.at(i) - 1) != s.end()) { count = 1; while (s.find(v[i] + 1) != s.end()) count++; res = max(res, count); } } cout << res; return 0; }
https://stackoverflow.com/questions/65876069/freezing-output-screen-in-vscode-after-entering-1 January 25, 2021 at 05:17AM
没有评论:
发表评论