自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(100)
  • 资源 (2)
  • 收藏
  • 关注

原创 java.lang.reflect.UndeclaredThrowableException原因和解决方法

在 Spring AOP中调用一个方法来进行数据验证一旦数据验证失败,抛出一个自定义的异常。然而,却抛出了java.lang.reflect.UndeclaredThrowableException查了一下,因为我的自定义异常继承Exception类。把它改为继承RuntimeException,再抛出的异常就是自己的自定义异常了

2017-06-08 14:36:52 38609 2

原创 Valid Palindrome

题目:判断字符串是否是回文字符串,只考虑字符串中的数字和字符,不考虑标点符号例如:"A man, a plan, a canal: Panama"是回文字符串"race a car" 不是回文字符串方法1:使用额外的内存空间    注意:测试时输入的字符串是带""引号的public class Solution { public boolean isPalindrome(S

2016-10-06 14:55:49 246

原创 Palindrome Number

题目:判断一个数是否是回文数字   回文数字就是正着读和反着读一样,比如12321.要求:不能使用额外的内存空间思路:反转数字,然后和反转前的数字对比,相等即返回truepublic class Solution { public boolean isPalindrome(int x) { //负数肯定不是回文数字 if (x < 0) {

2016-10-06 13:32:42 244

原创 Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321要求:不使用额外的内存空间。反转之后考虑越界问题。public class Solution { public int reverse(int x) { long res

2016-10-05 23:45:22 234

原创 用两个栈实现队列

题目1:用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。import java.util.Stack;public class Solution { Stack stack1 = new Stack(); Stack stack2 = new Stack(); public void push(int node) {

2016-10-05 20:10:36 212

原创 重建二叉树

题目:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如:输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。思路:二叉树的前序遍历时,第一个数字总是树的根节点的值。但在中序遍历中,根节点的值在序列的中间,左子树的结点的值位于根节点的值的左边,而右子树的结点

2016-10-05 16:56:54 200

原创 字符串替换

题目:请实现一个函数,将一个字符串中的空格替换成“%20”。例如:当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。思路:问题1:替换字符串,是在原来的字符串上做替换,还是新开辟一个字符串做替换!问题2:在当前字符串替换,怎么替换才更有效率(不考虑java里现有的replace方法)。      从前往后替换,后面的字符要不断往后移动

2016-10-05 11:27:41 272

原创 二维数组中的查找

题目1:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。例如:数组为:{{1,2,8,9},{2,4,9,12},{4,7,10,13},{6,8,11,15}} 目标值为7;返回true解题思路:从左下角或者右上角开始,我以右上角为例,右上角的元素和目标值比较,如果大

2016-10-05 10:10:30 234

原创 求两个数的最小公倍数

两个数的最下公倍数 = 两个数的乘积 / 两个数的最大公约数import java.util.*;public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); while(scanner.hasNext()){

2016-09-23 11:10:14 593

原创 java 位操作符

位运算的应用场景:因为位运算的运算效率比直接对数字进行加减乘除高很多,所以当出现以下情景且对运算效率要求较高时,可以考虑使用位运算。情况1:题目描述输入一个int型的正整数,计算出该int型数据在内存中存储时1的个数。例如输入5,因为5 的二进制表示为101,所以输出为2.解题思路:普通方法是将5转换成二进制的形式,然后再遍历该二进制字符串,如果是1,则计数

2016-09-22 16:18:56 279

原创 Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1题意:反转一颗二叉树解题思路:直接获取根节点的左右节点,然后进行交换即可。方法一使用二叉树层次遍历。/** * De

2016-09-18 22:56:45 184

原创 Path Sum

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum

2016-09-18 11:26:05 193

原创 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 diffe

2016-09-18 10:43:31 272

原创 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.求二叉树的最短深度解法一:深度优先遍历DFS/**

2016-09-17 22:34:43 175

原创 Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.求二叉树的最大深度,采用深度优先遍历原则/** * Def

2016-09-17 21:52:08 311

原创 Binary Tree Level Order Traversal I和II 层次遍历二叉树

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 2

2016-09-17 21:13:19 308

原创 Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3

2016-09-17 18:07:50 237

原创 Same Tree

Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.判断两棵二叉树是否相

2016-09-17 16:34:06 169

原创 Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is

2016-09-09 16:40:01 130

原创 Add Two Numbers

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

2016-09-09 16:14:54 183

原创 Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in

2016-09-08 22:48:59 242

原创 Sort List

题意:对链表进行排序,要求的时间复杂度为O(n log n)。解题思路:O(nlogn)的排序有快速排序、归并排序、堆排序。这里使用归并排序,归并排序的基本思想是:找到链表的中间节点,然后递归对前半部分和后半部分分别进行归并排序,最后对两个以排好序的链表进行Merge。/** * Definition for singly-linked list. * public class L

2016-09-08 13:45:53 183

原创 Insertion Sort List

题意:实现链表的插入排序 插入排序是一种O(n^2)复杂度的算法,就是每次循环找到一个元素在当前排好的结果中相对应的位置,然后插进去,经过n次迭代之后就得到排好序的结果了。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next;

2016-09-08 10:40:04 161

原创 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 to 

2016-09-07 23:51:57 270

原创 Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space? 题

2016-09-07 22:33:04 190

原创 Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of

2016-09-07 09:55:40 221

原创 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.题意:给定一个链表和一个k值,将链表向右旋转K个位置/

2016-09-06 18:02:57 181

原创 Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value

2016-09-05 17:00:07 191

原创 Palindrome Linked List 回文链表

Given a singly linked list, determine if it is a palindrome.题意: 判断一个链表是否是回文链表,回文链表就是无论从左读还是从右读都一样例如    1->2->3->2->1 需要注意的是空链表和只有一个节点的链表都是回文链表解题思路:反转链表,将链表后半段原地翻转,再将前半段、后半段依次比较,判断是否相等该方法时间复杂度为

2016-09-05 16:42:15 188

原创 Reverse Linked List I,II

Reverse a singly linked list.题意:反转链表方法一:遍历思路:使用辅助节点dummy。初始化时dummy..next指向head,并从第二个节点开始遍历,把遍历过的节点一次插入在dummy节点之后,最后返回dummy.next即可/** * Definition for singly-linked list. * public class Lis

2016-09-05 12:40:29 187

原创 Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5题意:去除链表中的目标元素。链表中的值可能有重复

2016-09-05 10:11:22 183

原创 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 ↘

2016-09-05 09:47:17 134

原创 Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?题意:判断链表中是否有环思路:采用快慢指针的方法,快指针走两步,慢指针走一步,如果有环,则总有相遇的时候即快慢指针相等的时候/** * Definitio

2016-09-04 23:36:19 143

原创 Remove Duplicates from Sorted List

题意:输入一个有序链表,删除重复元素,

2016-09-04 23:15:17 159

原创 Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y

2016-09-04 22:14:10 233

原创 Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.合并两个有序链表,返回合并后的有序链表头由于两个数去链表可能为空,所以增加一个dummy节点,时dummy

2016-09-04 16:59:47 159

原创 Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2016-09-04 13:46:42 181

原创 Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [

2016-09-03 10:57:16 205

原创 Majority Element II

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.找出数组中元素个数超过n/3的元素。解题思路: 忘了在哪看见过这个的数学证明,数组中超

2016-09-03 09:50:36 185

原创 Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.数组包含n个不同的数,这些数来自0, 1, 2, ..

2016-09-02 23:15:23 246

druid-1.1.22.zip

druid-1.1.22,请注意properties文件中的配置,如有引用请结合自身修改

2021-05-16

C3P0-0.9.2.1、commons-dbcp2-2.8.0、commons-pool2-2.9.0、mysql-connector-java-8..zip

包含:C3P0-0.9.2.1、commons-dbcp2-2.8.0、commons-pool2-2.9.0、mysql-connector-java-8.0.25

2021-05-16

空空如也

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

TA关注的人

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