- 博客(8)
- 收藏
- 关注
转载 【笔面试】字符流和字节流的区别以及如何解决乱码问题
工作中经常遇到java编码问题,由于缺乏研究,总是无法给出确切的答案,这个周末在网上查了一些资料,在此做些汇总。 问题一:在java中读取文件时应该采用什么编码?Java读取文件的方式总体可以分为两类:按字节读取和按字符读取。按字节读取就是采用InputStream.read()方法来读取字节,然后保存到一个byte[]数组中,最后经常用new String(byte[]
2015-10-19 17:41:46
6663
原创 Java知识点梳理内部类
内部类是指在一个外部类的内部再定义一个类。类名不需要和文件夹相同。*内部类可以是静态static的,也可用public,default,protected和private修饰。(而外部类即类名和文件名相同的只能使用public和default)。*四种类型:常规内部类 静态内部类 局部内部类 匿名内部类 注意:内部类是一个编译时的概念,一旦编译成功,就会成为完全不同的两类。
2015-09-29 11:35:00
488
原创 常见题目之n的阶乘末尾有多少个0
问题:N的阶乘(N!)中的末尾有多少个0? 例如:N = 5,N! = 120.末尾有1个0.解答:将N的阶乘看为10的M次方的乘积,末尾就有M个0。将N的阶乘进行分解可以得到:2的X次方,3的Y次方,5的Z次方,7的T次方的乘积。10=2*5,所以M只和X、Z有关,每一对2和5相乘都能得到10,于是M=min(X,Z),而一般情况下X>Z,即偶数个数肯定要大于5的
2015-09-29 10:55:24
2525
原创 【leetcode】二叉树的LCA问题:Lowest Common Ancestor of a Binary Tree
还是递归问题,定义left和right递归调用原函数,直到叶子结点为止。判断两个输入参数的父节点,有三种情况:第一,分别为左右树,父节点为root (第一个if条件)第二,遍历到P和Q时,将其返回给left和right,(第二个if条件)第三,根据left和right的值进行判断,父节点是左边还是右边并返回对应值(第三个if条件)。/** * Definition for
2015-07-14 19:47:51
908
原创 Number of Digit One 【leetcode】
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6, because digit 1 occurred in the follow
2015-07-09 10:31:36
560
原创 Merge Sorted Array 【leetcode】
Given two sorted integer arrays nums1 and nums2, merge nums2 intonums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal tom + n) to hold a
2015-07-09 09:47:59
318
原创 第一个自己完成的leetcode( JAVA) Implement Queue using Stacks
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front element. em
2015-07-08 09:51:38
384
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人