shampoo
shampoo
谢谢霍老师😳
位运算不熟练的同学,可以用bitset 嘿嘿 ```c++ class Solution { public: bool canPartitionKSubsets(vector &nums, int k) { typedef bitset bs20; if (k > nums.size())return false; int sum = 0; for (int i: nums)sum +=...
个人常用的螺旋矩阵的遍历方式,感觉比较易懂O(∩_∩)O ``` c++ const constexpr int dirs[4][2]={ {0,1},{1,0},{0,-1},{-1,0} }; class Solution { public: vector spiralOrder(vector& matrix) { int m=matrix.size(),n=matrix[0].size(); int size=m*n; vectorans; int i=0,j=0,curdir=0; while(ans.size()
同列判断用y记录,斜线判断xdy,xay PS:开200 是为了防止出现负数下标 ``` c++ class Solution { public: vector solveNQueens(int n) { typedef vector vs; vectorans; vs path(n,string(n,'.')); bool y[10]={0},xdy[200]={0},xay[200]={0}; functionbacktrack=[&](int row){ if(row==n){ ans.push_back(path); return ; } for(int i=0;i
> I see the use case for `$emits` but I'd like to understand how they are better than a callback function. For example: > > ``` > > > >...
$emit is equivalent to the callback function, why not use the callback function directly? Why add a layer of $emit in the middle?
> $emit is equivalent to the callback function, why not use the callback function directly? Why add a layer of $emit in the middle? Besides the different interface, I can't...