Problem lengthsort
User CoderBC
Submission Time 2025-05-09 12:29:26
Score 0
Max Time N/A
Max Memory N/A

Compile Error

lengthsort.cpp: In lambda function:
lengthsort.cpp:19:24: error: ‘n’ is not captured
19 | for(int i = 0; i < n; i ++){
| ^
lengthsort.cpp:14:35: note: the lambda has no capture-default
14 | sort(arr.begin(), arr.end(), [](const string &a, const string &b) {
| ^
lengthsort.cpp:8:9: note: ‘int n’ declared here
8 | int n;
| ^
lengthsort.cpp:20:17: error: ‘arr’ is not captured
20 | cout << arr[i] <<endl;
| ^~~
lengthsort.cpp:14:35: note: the lambda has no capture-default
14 | sort(arr.begin(), arr.end(), [](const string &a, const string &b) {
| ^
lengthsort.cpp:10:20: note: ‘std::vector<std::__cxx11::basic_string<char> > arr’ declared here
10 | vector<string> arr(n);
| ^~~
lengthsort.cpp: