自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(10)
  • 收藏
  • 关注

原创 排序

56. 合并区间class Solution { public int[][] merge(int[][] intervals) { int len = intervals.length; //将给定数组intervals排序-->重写sort排序 Arrays.sort(intervals, new Comparator<int[]>() { @Override public int

2021-05-24 11:02:27 49

原创 贪心算法

122. 买卖股票的最佳时机 IIclass Solution { public int maxProfit(int[] prices) { int sum = 0; if (prices == null ||prices.length <= 1) { return 0; } for (int i = 1; i < prices.length; i++) { int pre

2021-05-19 14:19:24 61 1

原创 动态规划

5. 最长回文子串class Solution { public String longestPalindrome(String s) { int len = s.length(); if (len <= 1) return s; boolean[][] dp = new boolean[len][len]; for (int i = 0; i < len; i++) { dp[i][i] = tr

2021-05-11 22:42:42 66

原创 数学

9. 回文数public class Solution { public boolean isPalindrome(int x) { if(x < 0){ return false; }else{ String str = String.valueOf(x); for(int i = 0, j = str.length() - 1; i <= j; i++,j--){ if

2021-05-10 11:25:33 40

原创 回溯算法

131. 分割回文串class Solution { public List<List<String>> partition(String s) { List<List<String>> lists = new ArrayList<>(); if (s.length() == 0) return lists; helper(lists, new ArrayList<>(), s,

2021-05-02 16:24:22 45

原创 剑指Offer 51-60

剑指 Offer 53 - I. 在排序数组中查找数字 Iclass Solution { public int search(int[] nums, int target) { int n = nums.length; int first = findFirst(nums, target, n); int last = findLast(nums, target, n); return last - first + 1; }

2021-05-02 14:32:33 46

原创 二分查找

35. 搜索插入位置class Solution { public int searchInsert(int[] nums, int target) { int low = 0; int hight = nums.length - 1; int ans = nums.length; while (low <= hight) { int mid = low + (hight - low) / 2;

2021-04-29 21:53:52 50

原创 树,递归,深度优先算法

109. 有序链表转换二叉搜索树方法一:将链表的方式转化为108题的数组的方式/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) {

2021-04-27 10:48:59 38

原创 剑指Offer 11-20

剑指 Offer 11. 旋转数组的最小数字class Solution { public int minArray(int[] numbers) { int low = 0; int high = numbers.length - 1; int mid = 0; while (low < high) { mid = low + (high - low) /2; if (numbe

2021-04-23 15:48:50 39

原创 剑指offer 2-10

##剑指offer###面试题2:单例模式public class Singleton { public Singleton () {} public static Singleton instance = null; public static Singleton getInstance() { if (instance == null) { synchronized (Singleton.class ) { //使用同步机制

2021-04-19 20:00:52 81

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除