![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java
皮卡丘zql
这个作者很懒,什么都没留下…
展开
-
剑指offer-4
题目描述大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。n<=39public class Solution { public int Fibonacci(int n) { int n1=0; int n2=1; int n3=0; if(n<=0)...原创 2019-06-20 16:01:21 · 90 阅读 · 0 评论 -
剑指offer-5
题目描述一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果)。public class Solution { public int JumpFloor(int target) { int n1=1; int n2=2; int n3=0; if(targe...原创 2019-06-20 16:43:17 · 93 阅读 · 0 评论 -
剑指offer-6
题目描述(变态跳台阶)一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。public class Solution {public int JumpFloorII(int target) { if (target <= 0) { return -1; ...原创 2019-06-21 13:55:03 · 63 阅读 · 0 评论 -
剑指offer-7
题目描述我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?public class Solution { public int RectCover(int target) { if(target<=0) return 0; else...原创 2019-06-21 14:20:31 · 95 阅读 · 0 评论 -
剑指offer-8
题目描述输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构)思路:1、首先设置标志位result = false,因为一旦匹配成功result就设为true,剩下的代码不会执行,如果匹配不成功,默认返回false2、递归思想,如果根节点相同则递归调用DoesTree1HaveTree2(),如果根节点不相同,则判断tree1的左子树和t...原创 2019-07-11 20:41:05 · 102 阅读 · 0 评论 -
剑指offer-10
题目描述操作给定的二叉树,将其变换为源二叉树的镜像。代码public class Solution { public void Mirror(TreeNode root) { TreeNode temp=null; if(root!=null){ temp=root.right; root.rig...原创 2019-07-11 20:51:11 · 87 阅读 · 0 评论 -
反转字符串
package zql_jianzhi;public class Reverse { //StringBuffer/StringBuilder函数来翻转字符串 public static String reverse1(String str) { return new StringBuffer(str).reverse().toString(); }...原创 2019-07-30 17:50:56 · 125 阅读 · 0 评论