publicclassSolution{ /** * @param n, m: positive integer (1 <= n ,m <= 100) * @return an integer */ publicintuniquePaths(int m, int n){ if(m == 0 || n == 0) return0; int[][] paths = newint[m][n]; for (int i = 0; i < m; i++) { paths[i][0] = 1; }
for (int i = 0; i < n; i++) { paths[0][i] = 1; }
for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { paths[i][j] = paths[i - 1][j] + paths[i][j - 1]; } } return paths[m - 1][n - 1]; } }
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
You must send this message from the thread on which the timer was installed. If you send this message from another thread, the input source associated with the timer may not be removed from its run loop, which could prevent the thread from exiting properly.
if (OSAtomicAnd32OrigBarrier(1, &_timerFlags.timerIsInvalidated)) // 原子操作 { return; }
// We're not worried about this warning because the selector we're calling doesn't return a +1 object. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" [self.target performSelector:self.selector withObject:self]; #pragma clang diagnostic pop
if (!self.repeats) { [self invalidate]; }
(5)释放
1 2 3 4 5 6 7 8 9 10 11 12 13
- (void)invalidate { // We check with an atomic operation if it has already been invalidated. Ideally we would synchronize this on the private queue, // but since we can't know the context from which this method will be called, dispatch_sync might cause a deadlock. if (!OSAtomicTestAndSetBarrier(7, &_timerFlags.timerIsInvalidated)) { dispatch_source_t timer = self.timer; dispatch_async(self.privateSerialQueue, ^{ dispatch_source_cancel(timer); ms_release_gcd_object(timer); }); } }