剑指offer
剑指offer刷题
超喜欢榴莲吖
许愿未来温暖阳光,满身宠爱
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
剑指offer——字符串(Leetcode)
面试题05. 替换空格题目请实现一个函数,把字符串 s 中的每个空格替换成"%20"。输入:s = “We are happy.”输出:“We%20are%20happy.”主要体会不同语言下的字符串替换使用。C++:class Solution {public: string replaceSpace(string s) { string ans; for(int i = 0; i<s.size(); i++) {原创 2020-06-24 20:57:37 · 135 阅读 · 0 评论 -
剑指offer——数学类问题集合(Leetcode)
面试题10- I. 斐波那契数列题目写一个函数,输入 n ,求斐波那契(Fibonacci)数列的第 n 项。斐波那契数列的定义如下:F(0) = 0, F(1) = 1F(N) = F(N - 1) + F(N - 2), 其中 N > 1.斐波那契数列由 0 和 1 开始,之后的斐波那契数就是由之前的两数相加而得出。答案需要取模 1e9+7(1000000007),如计算初始结果为:1000000008,请返回 1。输入:n = 5输出:5法一:直接按照递推式写即可。原创 2020-06-12 16:17:41 · 853 阅读 · 0 评论 -
739. 每日温度
题目根据每日 气温 列表,请重新生成一个列表,对应位置的输出是需要再等待多久温度才会升高超过该日的天数。如果之后都不会升高,请在该位置用 0 来代替。例如,给定一个列表 temperatures = [73, 74, 75, 71, 69, 72, 76, 73],你的输出应该是 [1, 1, 4, 2, 1, 1, 0, 0]。提示:气温 列表长度的范围是 [1, 30000]。每个气温的值的均为华氏度,都是在 [30, 100] 范围内的整数。使用单调栈,栈内维护递减序列。注意,栈中存放的是数原创 2020-06-11 21:12:49 · 167 阅读 · 0 评论 -
剑指offer——数组+矩阵合集(Leetcode)
面试题03. 数组中重复的数字题目这道题很简单,用set和map都可以。class Solution { public int findRepeatNumber(int[] nums) { Set<Integer> set=new HashSet<Integer>(); int repeat=-1; for(int num:nums){ if(!set.add(num)){原创 2020-06-07 10:18:11 · 268 阅读 · 0 评论 -
剑指offer——链表 + 栈 + 队列合集(LeetCode)
面试题03. 数组中重复的数字题目这道题很简单,用set和map都可以。class Solution { public int findRepeatNumber(int[] nums) { Set<Integer> set=new HashSet<Integer>(); int repeat=-1; for(int num:nums){ if(!set.add(num)){原创 2020-06-06 11:26:04 · 204 阅读 · 0 评论 -
剑指offer——二叉树集合(LeetCode)
面试题07.重建二叉树题目链接前序遍历找到当前子树根节点中序遍历将左右子树继续下分/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { public TreeNode原创 2020-06-02 22:40:25 · 198 阅读 · 0 评论
分享