CHuiL

48. Rotate Image

leetcode

题目 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input 2D ma...

240. Search a 2D Matrix II

leetcode

题目 Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right. Intege...

19. Remove Nth Node From End of List

leetcode

题目 Given a linked list, remove the n-th node from the end of list and return its head. 题意 删除链表倒数第n个节点,返回头节点 题解 寻找倒数第n个节点,就是使用快慢两个指针,快的先走n-1步,然后再走慢的,这样快的到尾节点时慢节点所在位置就是倒数第n个了。 而这里需要删除某个节点,所以需要在设置一个...

73. Set Matrix Zeroes

leetcode

题目 Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use ...

33. Search in Rotated Sorted Array

leetcode

题目 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. 题意 题目很好理解,就是给定一个矩阵,其中出现0的行列也全部置0 例子 Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: ...

33. Search in Rotated Sorted Array

leetcode

题目 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). You are given a target value to search. If ...

54. Spiral Matrix

leetcode

题目 Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. 题意 顺时针螺旋输出数组元素 题解 并没有太多复杂的解法,就只是单纯的按顺时针顺序一个一个输出,只是要注意好细节问题,每次按一个方向输出,一个方向上就需要固定行或列,然后遍历...

go中的非协作式调度

go学习记录

协作式调度与非协作式调度 抢占式多任务处理是计算机操作系统中,一种实现多任务处理的方式,相对于协作式多任务处理而言。协作式环境下,下一个进程被调度的前提是当前进程主动放弃时间片;抢占式环境下,操作系统完全决定进程调度方案,操作系统可以剥夺耗时长的进程的时间片,提供给其它进程。 Go1.12之前的协作式调度 在每个函数或方法的入口加上一段额外的代码,让runtime有机会检查是否需要执行抢占...

78. Subsets (含组合和排序)

leetcode

题目 Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. 题意 题目很好理解,就是求数组的所有组合 题解 解法就是使用求组合的方法 代码 var an...

62. Unique Paths

leetcode

题目 A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach ...