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 数组
JZ06 旋转数组的最小数字 Solution 二分查找 12345678910111213141516class Solution {public: int minNumberInRotateArray(vector<int> rotateArray) { int n = rotateArray.size(); if (n == 0) return 2021-10-06 algo nowcoder 二分法
JZ05 用两个栈实现队列 Solution 1234567891011121314151617181920212223class Solution{public: void push(int node) { stack1.push(node); } int pop() { if (stack2.empty()) { 2021-10-06 algo nowcoder 栈
JZ04 重建二叉树 Solution 根据索引来划分区间 1234567891011121314151617181920212223242526272829303132333435363738394041/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * T 2021-10-06 algo 二叉树 nowcoder
JZ02 替换空格 Solution 原字符串扩容 12345678910111213141516171819202122232425262728class Solution {public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * @param s string字符串 * @return string字符串 2021-10-06 algo 字符串 nowcoder
JZ01 二维数组中的查找 Solution 二分查找每一行 12345678910111213141516171819class Solution {public: // 把每一行看成有序递增的数组,利用二分查找 bool Find(int target, vector<vector<int> > array) { int n = array 2021-10-06 algo nowcoder 数组
JZ03 从尾到头打印链表 Solution 迭代法 12345678910111213141516171819202122/*** struct ListNode {* int val;* struct ListNode *next;* ListNode(int x) :* val(x), next(NULL) {* 2021-10-06 algo 链表 nowcoder
实现 BloomFilter 简介日常开发中,我们常常需要面对这样一个场景,判断一个元素是否存在集合当中,如我的这个需求,判断用户是否为新用户。一般数据量比较少的时候,很好处理,Java和Redis都提供了Set这个数据结构,我们可以直接调用方法来进行判断即可。但是当数据量比较大时,无论是Java亦或者是Redis中的Set都会占据相当一部分内存,影响整体性能。因此,BloomFilter应运而生。BloomFilter可以理 2021-08-30 algo 面试题
1116 打印零与奇偶数 假设有这么一个类: 123456class ZeroEvenOdd { public ZeroEvenOdd(int n) { ... } // 构造函数 public void zero(printNumber) { ... } // 仅打印出 0 public void even(printNumber) { ... 2021-08-25 algo leetcode 二叉树