自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 阅读java源码--String

本文章源码来源JDK1.8目录实现方式构造方法空构造 "".valueString 为参数char[] 为参数字符的UNicode编码数组(int[])byte[] 不常用 *StringBuffer为参数StringBuilder为参数主要方法length()isEmpty()charAt(int index)equals(Object...

2020-03-16 18:01:50 173 1

原创 Leetcode挑战:Valid Parentheses(有效的括号)

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of b...

2019-08-16 11:45:50 110

原创 Leetcode挑战:Remove Nth Node From End of List(删除链表中倒数第n个节点)

Given a linked list, remove the n-th node from the end of list and return its head.(Givennwill always be valid)给定一个链表,删除链表的倒数第n个节点,并且返回链表的头结点。(给定的n均有效)给定一个链表: 1->2->3->4->5, 和 n =...

2019-08-14 16:00:15 107

原创 单链表(ListNode)及操作其基础方法

在做算法题的过程中,总会遇见单链表相关的题,在Java中用需要自己定义一个ListNode类来生成链表对象,闲来无事就写了一个ListNode,对链表的操作直接在ListNode里进行了,实际用处不大,仅供参考。如有问题烦请大家指正。下边上代码:/** * 链表 * */public class ListNode<T> { /** * 数据域 */ priv...

2019-08-12 16:25:59 4487

原创 Leetcode挑战:Maximum Subarray(最大子序和)

Given an integer array nums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.给定一个整形数组(至少包含一个元素),找到其中连续最大和的子数组,输出最大和。输入1: {-2,1,-3,4,-1,2...

2019-08-05 11:44:03 87

原创 Leetcode挑战:Invert Binary Tree(翻转二叉树)

翻转一颗二叉树 用例: 源二叉树 4 / \ 2 7/ \ / \1 3 6 9 镜像二叉树 4 / \ 7 2/ \ / \9 6 3 1解题思路:递归解法,每次交换左右节点的位置,相对来说比较简单。...

2019-08-01 16:49:09 107

原创 Leetcode挑战:Largest Number(最大数)

Given a list of non negative integers, arrange them such that they form the largest number.给定一组非负整数,重新排列它们的顺序使之组成一个最大的整数。用例:输入: [3,30,34,5,9]输出: 9534330代码较少,解题思路在注释里...

2019-07-31 17:21:07 100

原创 Leetcode挑战:String to Integer(字符串转数值)

请你来实现一个atoi函数,使其能将字符串转换成整数。首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号;假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。该字符串除了有效的整数部分之后也可能会存在多余的字符,这些字符可...

2019-07-15 14:58:49 115

原创 Leetcode挑战:Reverse Integer(反转整数)

Given a 32-bit signed integer, reverse digits of an integer.给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。假设我们的环境只能存储得下 32 位的有符号整数,则其数值范围为[−2^31, 2^31− 1]。请根据这个假设,如果反转后整数溢出那么就返回 0。解题思路不难,需要考虑int数值溢出问题,...

2019-07-15 11:07:53 91

原创 Leetcode挑战: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.编写一个程序判断给定的数是否为丑数。丑数就是只包含质因数2, 3, 5的正整数。示例 1:输入...

2019-07-12 18:20:42 143

原创 Leetcode挑战:Add Two Numbers(两数相加)

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...

2019-07-11 17:39:37 89

原创 java =与== 一道小题引发的思考

第一眼看这个题,以为会编译不通过,结果正确答案会输出 true。后来经过下边的评论以及亲身试验得知,JAVA的赋值运算是有返回值的,赋了什么,返回什么,所以if里边只能有布尔型的赋值语句,如果这题是==就返回false了(个人认为和是不是封装类型没有太大关系,因为只是涉及到自动拆箱,主要还是赋值运算有返回值)ps:=:是一个赋值运算符,赋给某个变量一个具体的值。==:是一个...

2019-06-25 17:59:04 100

原创 Leetcode挑战: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.给定一个二叉树,找到它的最小深度。最小深度是从根节点到最近叶节点的最短路径上的节...

2019-06-17 00:11:14 116

原创 leetcode挑战:evaluate-reverse-polish-notation(逆波兰表达式计算)

Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.计算逆波兰表达式的结果,表达式内容包括数字和有效的运算符(+ - * /)输入...

2019-06-14 17:27:38 168

空空如也

空空如也

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

TA关注的人

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