case 0:ret[nums[1][0]]=(char*)malloc(sizeof(char)*15); strcpy(ret[nums[1][0]],"Gold Medal"); break; case 1:ret[nums[1][1]]=(char*)malloc(sizeof(char)*15); strcpy(ret[nums[1][1]],"Sliver Medal"); break; case 2:ret[nums[1][2]]=(char*)malloc(sizeof(char)*15);...
给你单链表的头节点head,请你反转链表,并返回反转后的链表。 示例1: 输入:head = [1,2,3,4,5]输出:[5,4,3,2,1] 示例2: 输入:head = [1,2]输出:[2,1] 示例3: 输入:head = []输出:[] 提示: 链表中节点的数目范围是[0, 5000] ...
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
入环点到相遇点的距离为b,# 相遇点到入环点的距离为c;环长即为 b + c# 所以:慢指针走的路程:a + b# 快指针走的路程:a + b + k * (b + c)# 又因为快指针的速度是慢指针的两倍,那么时间相同时,路程也是两倍#
https://leetcode.com/problems/permutation-in-string/ https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string/ https://leetcode.com/problems/fruit-into-baskets/ https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/ ...
链接:https://leetcode-cn.com/problems/median-of-two-sorted-arrays/description/ 有两个大小为 m 和 n 的排序数组 nums1 和 nums2 。请找出两个排序数组的中位数并且总的运行时间复杂度为 O(log (m+n)) 。示例 1: ...
Parts of the problems don't provide C interface for solution, so I accomplished them with C++ Language. CompileCfiles using command: CompileC++files using command: g++ -std=c++11 -Wall src/bar.cpp -o bar OR You can build all the files usingmake(Use MinGW GCC and GNU Make on Windows)....
链接:https://leetcode.cn/problems/exclusive-time-of-functions 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 题意不难理解,思路是stack,理由是无论这里面涉及多少函数的递归调用,一定是后开始跑的函数先结束,符合stack的后进先出的原则。我们用题目给的第一个例子跑一下。这里我们还需要...
链接:https://leetcode.cn/problems/median-of-two-sorted-arrays 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 这个题是有时间复杂度的要求的,O(log (m+n))。如果没有这个要求,因为两个数组都是各自有序的,所以就可以把两个数组合并然后找中位数就行了。我这里给出最优解,思路参...
链接:https://leetcode-cn.com/problems/perfect-rectangle/description/ 题目 我们有 N 个与坐标轴对齐的矩形, 其中 N > 0, 判断它们是否能精确地覆盖一个矩形区域。 每个矩形用左下角的点和右上角的点的坐标来表示。例如, 一个单位正方形可以表示为 [1,1,2,2]。 ( 左下角的点的坐标为 (1, 1) 以...