- 博客(50)
- 收藏
- 关注
原创 windows 环境下 ANTLR 的安装和使用
windows 环境下 ANTLR 的安装和使用1、首先要下载 ANTLR 的 jar 包我这里使用的是 antlr-4.4-complete.jar,下载地址 [: https://pan.baidu.com/s/1f13vLQdgU0I-RR1jOlGSww ][6] 密码: 3v2e 下载的文件夹中包含下面图片中的文件,除 antlr-4.4-complete.jar 包外,还...
2018-05-27 23:25:19
2217
2
原创 LeetCode172. Factorial Trailing Zeroes
172.Factorial Trailing Zeroes题意:Given an integer n, return the number of trailing zeroes in n!. 给定一个正整数n,返回 n!的末尾的 0 的个数。 Note: Your solution should be in logarithmic time complexity.我的想法:就只想到了用暴力求解,
2017-12-16 14:35:55
252
原创 LeetCode169. Majority Element
169.Majority Element题意:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the m
2017-12-16 14:34:53
261
原创 LeetCode167. Two Sum II - Input array is sorted
167.Two Sum II - Input array is sorted题意:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. 给一个已经按照升序排列的整数数组,找到两个
2017-12-12 22:05:43
238
原创 LeetCode160. Intersection of Two Linked Lists
160.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:
2017-12-12 17:15:58
223
原创 LeetCode671. Second Minimum Node In a Binary Tree
671.Second Minimum Node In a Binary Tree题意:Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the n
2017-12-11 10:34:47
362
原创 LeetCode687. Longest Univalue Path
687.Longest Univalue Path题意:Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root. 给定一棵二叉树,寻找符合条件的最长路
2017-12-10 18:31:06
285
原创 LeetCode113. Path Sum II
113.Path Sum II 题意Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. 给定一个二叉树和一个数字,找到所有从根结点到叶节点的路径,满足和和给定数字相等。 For example: Given the below binary
2017-12-10 15:32:28
254
转载 java String 缓冲池
java 中 String 创建详细解释字符串对象是一种特殊的对象。String 类是一个不可变的类。也就说,String 对象 一旦创建就不允许修改。 String 类有一个对应的 String 池,也就是 String pool。每一个内容相同的字符串对 象都对应于一个 pool 里的对象。1.String创建String s = new String("abc"); String s
2017-12-07 15:11:39
579
原创 使用Mybatis-Generator自动生成代码
这两天需要用到MyBatis的代码自动生成的功能,由于MyBatis属于一种半自动的ORM框架,所以主要的工作就是配置Mapping映射文件,但是由于手写映射文件很容易出错,所以可利用MyBatis生成器自动生成实体类、DAO接口和Mapping映射文件。这样可以省去很多的功夫。工具mybatis-generator-core-1.3.2步骤1、相关文件:关于 Mybatis-Generator
2017-12-03 18:54:11
324
原创 LeetCode155. Min Stack
155.Min Stack Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. 本题设计一个栈,包括4个功能,入栈push(),出栈pop(),返回栈顶元素top(),返回栈的最小值getMin();push(x) -- Push element x
2017-11-29 10:08:46
218
原创 LeetCode109. Convert Sorted List to Binary Search Tree
109.Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 给定一个单元链表,元素按照升序排列,将其转换为高度平衡的BST。 平衡二叉查找树的特点是
2017-11-27 17:28:07
265
原创 LeetCode530. Minimum Absolute Difference in BST
530.Minimum Absolute Difference in BST Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. BST 的最小绝对差值。Example:Input: 1 \
2017-11-27 15:41:55
325
原创 **LeetCode137. Single Number II_M
137.Single Number II_M Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note: Your algorithm should have a linear runtime
2017-11-13 21:12:04
300
原创 LeetCode2. Add Two Numbers
2.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 nu
2017-11-09 21:42:52
208
原创 LeetCode142. Linked List Cycle II
142.Linked List Cycle IIGiven 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 ext
2017-11-08 17:27:25
265
原创 LeetCode141. Linked List Cycle
141.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? class ListNode { int val; ListNode next; ListNode(int
2017-11-08 16:18:27
201
原创 LeetCode136. SingleNumber
136.SingleNumberGiven an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it with
2017-11-06 22:34:27
202
原创 LeetCode125. Valid Palindrome
125.Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a palindrome. “race
2017-11-05 20:05:55
302
原创 LeetCode122. Best Time to Buy and Sell Stock II
122.Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many t
2017-11-05 17:13:01
563
原创 LeetCode121. Best Time to Buy and Sell Stock
121.Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one a
2017-11-05 15:05:10
307
原创 LeetCode119. Pascal's Triangle II
119.Pascal’s Triangle II Given an index k, return the kth row of the Pascal’s triangle.For example, given k = 3, Return [1,3,3,1].Note: Could you optimize your algorithm to use only O(k) extra space
2017-11-01 16:39:56
264
原创 LeetCode118. Pascal's Triangle
118.Pascal’s Triangle 帕斯卡尔三角形也就是杨辉三角形 发现规律: * 每一行中数的个数与行号相等; * 每一行中除了第一个和最后一个元素,其他元素是上一行中相邻两个元素之和; 由这两个规律可以得到杨辉三角形。 方法一: 这里 i 代表层数,从 1 开始,List中先插入非 1 元素,最后插入首尾两个1。public List<List<Integer>> gen
2017-10-31 11:45:19
238
原创 LeetCode112. Path Sum
112.Path Sum 使用递归的方法,要注意题意只要有一个叶子节点符合要求就返回 true,所以return 语句回一个或语句.public boolean hasPathSum(TreeNode root, int sum) { if(root == null) return false; if(root.left == null && root.
2017-10-30 22:01:11
219
原创 LeetCode111. Minimum Depth of Binary Tree
111.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
2017-10-30 21:01:45
239
原创 LeetCode110. Balanced Binary Tree
110.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 e
2017-10-30 20:28:00
379
原创 LeetCode108. Convert Sorted Array to Binary Search Tree
108.Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. BST:Binary sorted tree(二叉排序树).即按照中序遍历的方式遍历这棵树,结果值按照升序排列
2017-10-29 21:51:33
467
原创 LeetCode107. Binary Tree Level Order Traversal II
107.Binary Tree Level Order Traversal II public class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; }}方法一: 受上一题104.MaximumDepthofBinaryTree的启发,使用队列来做,
2017-10-27 16:00:25
221
原创 LeetCode104. Maximum Depth of Binary Tree
104.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.public cl
2017-10-24 22:00:42
170
原创 Java 中的 this 和 super
this( ) 函数:this是自身的一个对象,代表对象本身,可以理解为:指向对象本身的一个指针。 this的用法在java中大体可以分为3种:1.普通的直接引用这种就不用讲了,this相当于是指向当前对象本身。2.形参与成员名字重名,用this来区分:class Person { private int age = 10; public Person(){ System.
2017-10-23 16:33:14
220
原创 LeetCode101. Symmetric Tree
101.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:
2017-10-22 13:44:28
259
原创 LeetCode100. Same Tree
100.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. 给定两个
2017-10-19 21:23:40
318
原创 LeetCode 88. Merge Sorted Array
88.Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume that nums1 has enough space (size that is greater or equal to m
2017-10-19 11:17:33
205
原创 Java 整数溢出
int 类型在 Java 中是“有符号”的。所谓“有符号”就是有正负。 在计算机中用二进制表示所有的信息,这个符号的区别就看首位。 首位如果是 0,就是正的,1 就是负的。正与负的区别也因此就在于取反加一。这不仅在 Java,在任何语言中都是这样的。 所谓数值溢出就会出现这个现象。Java 中的 int 总共就 32 位,正数上限的情况首位也只能是 0,其他位都可以是 1(就是 2^31-1
2017-10-14 19:33:52
1027
原创 Java 集合
上图是java 集合框架的接口继承图,集合中有两个基本接口:Collection 和 Map。Collection 实现了 Iterable 接口,所以所有实现了 Iterable 接口的类都能使用 Iterator 迭代器。 上图是Java 集合框架的类的继承图 实体集合/映射 接口 重复项 有序/排序 元素调用方法 实现类数据结构 值是否可为NULL
2017-10-12 15:56:09
299
原创 Java 产生随机数的三种方式
为什么说Java中的随机数都是伪随机数?什么是伪随机数?伪随机数是看似随机实质是固定的周期性序列,也就是有规则的随机。只要这个随机数是由确定算法生成的,那就是伪随机,只能通过不断算法优化,使你的随机数更接近随机。 (随机这个属性和算法本身就是矛盾的)通过真实随机事件取得的随机数才是真随机数。Java随机数产生原理Java的随机数产生是通过线性同余公式产生的,也就是说通过一个复杂的算法
2017-10-09 22:18:57
13777
2
原创 LeetCode21. 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.开始不了解链表,不知道Li
2017-10-01 16:08:14
303
原创 LeetCode83. Remove Duplicates from Sorted List
83.Remove Duplicates from Sorted List题意: 给一个已排序的链表,删除重复的元素,使得所有元素只出现一次。 Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return
2017-10-01 15:58:11
272
原创 **LeetCode 70. Climbing Stairs
70.Climbing Stairs 题意: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Giv
2017-09-28 15:51:48
308
转载 对Java方法参数按值传递的理解
对Java方法参数按值传递的理解标签: 值传递 引用传递 方法参数2017-02-28 22:37 322人阅读 评论(0)收藏举报分类: Java(10) 作者同类文章X版权声明:本文为博主原创文章,未经博主允许不得转载。今天看到(Java核心计数)Java方法对参数按值传递的
2017-09-25 22:32:03
261
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人