JZ16 合并两个排序的链表 Solution 递归法 1234567891011121314151617181920212223/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/// 递归法class Solution { 2021-10-06 algo 链表 nowcoder
JZ15 反转链表 Solution 递归法 1234567891011121314151617181920/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/class Solution {public: 2021-10-06 algo 链表 nowcoder
JZ14 链表中倒数最后k个结点 Solution 双指针 1234567891011121314151617181920212223242526272829303132333435/** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : val(x), next(nullptr) {} 2021-10-06 algo 链表 nowcoder
JZ13 调整数组顺序使奇数位于偶数前面 Solution 另外开辟数组,双指针会导致相对位置改变 123456789101112131415161718192021222324252627class Solution {public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param array int整型vect 2021-10-06 algo nowcoder 数组
JZ12 数值的整数次方 Solution 123456789101112131415161718class Solution {public: double Power(double base, int exponent) { if (exponent < 0) { base = 1 / base; exponen 2021-10-06 algo 数学 nowcoder
JZ11 二进制中1的个数 Solution 位运算 1234567891011class Solution {public: int NumberOf1(int n) { int res = 0; while (n != 0) { res++; n = n & (n-1); 2021-10-06 algo 数学 nowcoder
JZ10 矩形覆盖 Solution 本质还是斐波那契数列,递归法或迭代法 12345678class Solution {public: int rectCover(int number) { if (number < 3) return number; int res = rectCover(number - 1) + rectCover(n 2021-10-06 algo 动态规划 nowcoder
JZ09 跳台阶扩展问题 Solution 动态规划 123456789101112131415class Solution {public: int jumpFloorII(int number) { if (number < 2) return number; vector<int> dp(number + 1, 0); 2021-10-06 algo 动态规划 nowcoder
JZ08 跳台阶 Solution 本质等同于斐波那契数列 123456789101112class Solution {public: int jumpFloor(int number) { if (number < 2) return number; vector<int> dp(number + 1, 0); d 2021-10-06 algo 递归 nowcoder
JZ07 斐波那契数列 Solution 12345678910111213class Solution {public: int Fibonacci(int n) { if (n < 2) return n; int dp[2] = {0, 1}; for (int i = 2; i <= n; ++i) 2021-10-06 algo nowcoder 数组