自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

BridgeGeorge

专注于Android开发,架构和性能优化

  • 博客(115)
  • 资源 (3)
  • 收藏
  • 关注

原创 算法系列——二叉搜索树的第k个结点

题目描述给定一颗二叉搜索树,请找出其中的第k大的结点。例如, 5 / \ 3 7 /\ /\ 2 4 6 8 中,按结点数值大小顺序第三个结点的值为4。解题思路1,二叉搜索树的中序遍历是排序的,所以先进行中序遍历得到一个有序list 2,在该list里查找到第k个程序实现public class Solution { private ArrayList<TreeNode> res=new

2017-08-31 21:10:34 518

原创 算法系列——二叉树下一个结点

题目描述给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。解题思路 (1) 若该节点存在右子树:则下一个节点为右子树最左子节点(如图节点 B ) (2) 若该节点不存在右子树:这时分两种情况: 2.1 该节点为父节点的左子节点,则下一个节点为其父节点(如图节点 D ) 2.2 该节点为父节点的右子节点,则沿着

2017-08-31 09:51:26 505

原创 算法系列——构建乘积数组(剑指offer)

题目描述给定一个数组A[0,1,…,n-1],请构建一个数组B[0,1,…,n-1],其中B中的元素B[i]=A[0]A[1]…A[i-1]*A[i+1]…*A[n-1]。不能使用除法.解题思路下三角用连乘可以很容求得,上三角,从下向上也是连乘。 因此我们的思路就很清晰了,先算下三角中的连乘,即我们先算出B[i]中的一部分,然后倒过来按上三角中的分布规律,把另一部分也乘进去。程序实现

2017-08-30 20:31:27 454

原创 算法系列——数组中的重复数字(剑指offer)

题目描述在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的,但不知道有几个数字是重复的。也不知道每个数字重复几次。请找出数组中任意一个重复的数字。 例如,如果输入长度为7的数组{2,3,1,0,2,5,3},那么对应的输出是第一个重复的数字2。解题思路排序法直接对数组进行排序,然后遍历数组即可。 时间复杂度为O(nlogn).空间复杂度O(1)哈希表用哈希表统计每个数

2017-08-30 17:29:34 1619 1

原创 算法系列——不用加减乘除做加法(剑指offer)

题目描述写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。解题思路首先看十进制是如何做的: 5+7=12,三步走 第一步:相加各位的值,不算进位,得到2。 第二步:计算进位值,得到10. 如果这一步的进位值为0,那么第一步得到的值就是最终结果。第三步:重复上述两步,只是相加的值变成上述两步的得到的结果2和10,得到12。同样我们可以用三步走的方式计算二进制值相加: 5

2017-08-30 16:55:23 872 1

原创 算法系列——求1+2+3+...+n

题目描述求1+2+3+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。解题思路可以利用pow()方法和移位运算利用求和公式 (1+n)*n/2= (n²+n)>>1利用递归和短路求值原理int sum=n; sum>0&&((sum+=sum(n-1))>0)程序实现pow()方法和移位运算 public int Sum_

2017-08-30 16:26:43 3867 1

原创 算法系列——数组中出现次数超过一半的数字(剑指offer)

题目描述数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}。由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2。如果不存在则输出0。解题思路排序法将数组进行排序,数组中元素个数超过一半的元素必定在中间位置,直接返回中间位置的元素即可。 排序算法最好的平均时间复杂度为O(nlogn),空间复杂度为O(1)哈希表遍历

2017-08-29 11:32:46 1036

原创 算法序列——最长公共子序列

题目描述说明 最长公共子序列的定义:最长公共子序列问题是在一组序列(通常2个)中找到最长公共子序列(注意:不同于子串,LCS不需要是连续的子串)。该问题是典型的计算机科学问题,是文件差异比较程序的基础,在生物信息学中也有所应用。 https://en.wikipedia.org/wiki/Longest_common_subsequence_problem 样例 给出”ABCD”

2017-08-28 10:38:26 704

原创 算法系列——二叉搜索树和双向链表(剑指offer)

题目描述输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。解题思路程序实现

2017-08-28 10:32:16 581

原创 算法系列——顺时针打印矩阵II(Spiral Matrix II)

题目描述Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example, Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6

2017-08-25 18:15:46 682

原创 算法系列——顺时针打印矩阵(Spiral Matrix)

##题目描述Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]You

2017-08-25 17:57:30 757

原创 算法系列——调整数组顺序使奇数位于偶数前面(剑指offer)

题目描述输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。解题思路提供以下下两种方法相对位置不发生变化可以创建两个数组,分别存储原数组中奇数和偶数,然后在复制到原数组当中。 空间复杂度为O(n),时间复杂度为O(n)相对位置发生变化双指针法 1. 使指针l 向后遍历,直到指向

2017-08-25 16:57:46 748

原创 算法系列——替换空格(剑指offer)

##题目描述请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。

2017-08-25 12:27:32 818

原创 算法系列——从尾到头打印链表(剑指offer)

##题目描述输入一个链表,从尾到头打印链表每个节点的值。##解题思路###栈可以利用栈先进后出的特性,将结点依次进栈。最后再依次出栈即可。###递归法同样可以利用递归的方法。

2017-08-25 11:32:19 655

原创 算法系列——变态跳台阶(剑指offer)

##题目描述一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。

2017-08-25 10:08:59 533

原创 算法系列——矩形覆盖(剑指offer)

题目描述我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?解题思路本质是一个菲波那切数列,将n个2*1的小矩形无重叠地覆盖一个2*n的大矩形的方法数记为f(n)。以n=3,为例,当竖着放的时候,右边还剩下2*2的区域,这种情况下的覆盖方法记为f(2),当横着放在左上角的时候,左下角必须横着放一个2*1的小矩形,因此右边还剩

2017-08-25 09:40:39 1450

原创 算法系列——最长公共前缀(Longest Common Prefix)

题目描述Write a function to find the longest common prefix string amongst an array of strings.解题思路找字符串的最长公共前缀,比较简单。可以先找出最短的字符串。 然后将所有字符串左端对齐 以最短的字符串长度为边界范围,开始逐个字符扫描,直到遇到不相同的字符串 取子串即可。程序实现class Solution {

2017-08-24 21:13:55 1011

原创 算法系列——路径总和III(Path Sum III)

##题目描述You are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or a leaf, but it must g

2017-08-24 12:29:03 495

原创 算法系列——完全平方数(Perfect Squares)

##题目描述Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, ret

2017-08-24 11:51:16 1362

原创 算法系列——平衡二叉树判断(Balanced Binary Tree)

题目描述Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never d

2017-08-24 11:27:46 1056

原创 算法系列——排序链表(Sort List)

题目描述Sort a linked list in O(n log n) time using constant space complexity.解题思路程序实现public class Solution { public ListNode sortList(ListNode head) { //边界 if(head==null||h

2017-08-24 11:15:16 461

原创 算法系列——二叉树的最小深度(Minimum Depth of Binary Tree)

题目描述Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.解题思路程序实现public class Solut

2017-08-24 11:06:27 512

原创 算法系列——重排链表(Reorder List)

题目描述Given a singly linked list L: L0?L1?…?Ln-1?Ln, reorder it to: L0?Ln?L1?Ln-1?L2?Ln-2?…You must do this in-place without altering the nodes’ values.For example, Given {1,2,3,4}, reorder it t

2017-08-24 10:59:46 609

原创 算法系列——反转链表II(Reverse Linked List II)

题目描述 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given

2017-08-24 10:25:19 323

原创 算法系列——旋转链表(Rotate List)

题目描述Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.解题思路程序实现 if (head == null

2017-08-23 19:07:08 869

原创 算法系列——二叉树的最低公共祖先(Lowest Common Ancestor of a Binary Tree)

题目描述Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two no

2017-08-23 18:25:50 1590

原创 算法系列——相交链表(Intersection of Two Linked Lists)

题目描述Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2017-08-23 17:36:09 915

原创 算法系列——二叉搜索树的最低公共祖先(Lowest Common Ancestor of a Binary Search Tree)

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes

2017-08-23 17:09:57 689

原创 算法系列——丑数II(Ugly Number II)

题目描述Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10

2017-08-23 16:57:09 1007

原创 算法系列——丑数(Ugly Number)

题目描述Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since i

2017-08-23 14:57:43 950

原创 算法系列——加油站(Gas Station)

题目描述There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i t

2017-08-23 11:35:24 2609

原创 算法系列——跳跃游戏(Jump Game)

题目描述Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine

2017-08-23 11:09:14 818

原创 算法系列——存在重复元素III(Contains Duplicate III)

##题目描述Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference be

2017-08-23 09:29:51 509

原创 算法分析——二叉树后续遍历(Binary Tree Postorder Traversal)

题目描述Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1].Note: Recursive solution

2017-08-22 17:04:24 587

原创 算法系列——二叉树中序遍历(Binary Tree Inorder Traversal)

题目描述Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,3,2].Note: Recursive solutio

2017-08-22 16:50:54 816

原创 算法系列——二叉树先序遍历(Binary Tree Preorder Traversal)

题目描述Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3].Note: Recursive solution is triv

2017-08-22 16:41:44 1333

原创 算法系列——单词拆分(Word Break)

题目描述Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You ma

2017-08-22 15:56:17 753

原创 算法系列——子集II(Subsets II)

题目描述Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,2], a s

2017-08-22 11:08:31 449

原创 算法系列——下一个排列(Next Permutation)

题目描述Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest poss

2017-08-22 11:06:54 922

原创 算法系列——全排列II(Permutations II)

题目描述Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [ [1,1,2], [1,2,1],

2017-08-22 10:46:29 578

IpcBigBitmapDemo.zip

原文连接https://blog.csdn.net/ylyg050518/article/details/97671874

2019-07-29

SonarLint 代码检查工具

SonarLint 代码检查工具,IDEA 插件。

2016-11-04

空空如也

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

TA关注的人

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