剑指offer刷题总结
CRUD民工
做一只快乐的码农!
展开
-
面试题14- II. 剪绳子 II
import java.math.BigInteger; class Solution { public int cuttingRope(int n) { if(n <= 1) return 0; if(n == 2) return 1; if(n == 3) ...原创 2020-02-20 15:35:07 · 171 阅读 · 0 评论 -
面试题14- I. 剪绳子
class Solution { public int cuttingRope(int n) { if (n <= 1) { return 0; } if (n == 2) { return 1; } if (n == 3) { r...原创 2020-02-20 15:30:54 · 151 阅读 · 0 评论 -
面试题11. 旋转数组的最小数字
class Solution { public int minArray(int[] numbers) { if (numbers == null || numbers.length == 0) { return 0; } int left = 0; int right = numbers.leng...原创 2020-02-20 15:27:37 · 83 阅读 · 0 评论 -
面试题10- II. 青蛙跳台阶问题
class Solution { public int numWays(int n) { if (n <= 1) { return 1; } if (n == 2) { return 2; } long first = 1; long s...原创 2020-02-20 15:26:14 · 134 阅读 · 0 评论 -
面试题10- I. 斐波那契数列
class Solution { public int fib(int n) { if ( n <= 1) { return n; } long first = 0; long second = 1; for (int i = 2; i <= n; i++) { ...原创 2020-02-20 15:24:35 · 209 阅读 · 0 评论 -
面试题09. 用两个栈实现队列
class CQueue { public Stack<Integer> stack1; public Stack<Integer> stack2; public CQueue() { stack1 = new Stack<Integer>(); stack2 = new Stack<Integ...原创 2020-02-20 15:23:14 · 150 阅读 · 0 评论 -
面试题06. 从尾到头打印链表
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public int[] reversePrint(...原创 2020-02-20 15:19:37 · 104 阅读 · 0 评论 -
面试题05. 替换空格
class Solution { public String replaceSpace(String s) { if (s == null) { return null; } StringBuffer sb = new StringBuffer(); for (int i = 0; i < s...原创 2020-02-20 15:18:09 · 63 阅读 · 0 评论 -
面试题04. 二维数组中的查找
class Solution { public boolean findNumberIn2DArray(int[][] matrix, int target) { if (matrix == null || matrix.length == 0) { return false; } int row = 0; ...原创 2020-02-20 15:16:26 · 94 阅读 · 0 评论 -
面试题03. 数组中重复的数字
class Solution { public int findRepeatNumber(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int[] temp = new int[nums.length]; for (...原创 2020-02-20 15:12:25 · 96 阅读 · 0 评论