C++ Function Lambda

Section A #include <functional> #include <iostream> int main() { int a = 5, b = -5; auto lmbd = [&](int a) -> void { --a; --b; }; std::function<void(int)> func = [&](int a) -> void { --a; --b; }; func(a); std::cout << a << ' ' << b << std::endl; return 0; } Section B 698. 划分为k个相等的子集 - 力扣(LeetCode)(超时写法) class Solution { public: bool canPartitionKSubsets(vector<int> &nums, int k) { const int n = nums....

April 21, 2023 · 1 min · Cyan