- 博客(9)
- 收藏
- 关注
原创 416. Partition Equal Subset Sum
416. Partition Equal Subset Sum题目:假设一个非空数组中仅包含正整数,判断是否可以将该数组分为两个子数组,使得两个子数组中元素的和相等题解:这是一个0-1背包问题,假设原数组的和为sum,问题可以转化为:找到一个原数组的子集,使其子集内的元素之和等于sum/2。方案一:递归算法假设原数组为nums,其中有n个数,其和为sum,那么需要在这n个数中找出一个子集使...
2019-04-24 20:11:14 236
原创 Spring bean的生命周期
Spring对bean进行实例化。 spring将值和bean的引用注入到bean对应的属性中。 如果bean实现了BeanNameAware接口,Spring将bean的ID传递给setBeanName()方法。 如果bean实现了BeanFactoryAware几口,Spring将调用setBeanFactory()方法,将BeanFactory 容器示例传入。 如果bean实现了Ap...
2019-01-08 15:21:07 206
原创 2018网易互娱秋招笔试题
1. 计算税import java.util.Scanner;public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); ...
2018-08-09 22:08:53 2856
原创 synchronized同步三种使用方法
1.同步代码块synchronized (对象){ //代码块}上面的对象可以是任意对象,但必须为同一对象2.同步函数synchronized void method(){ //代码}同步方法使用的同步对象为该方法所属类本身,即this3.同步静态方法synchronized static void method(){ //代码}
2017-12-22 16:58:46 1691
原创 389. Find the Difference
Q:Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that
2016-11-29 20:43:47 260
原创 283. Move Zeroes
Q:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling
2016-11-27 13:05:42 335
原创 387. First Unique Character in a String
Q:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.问题:给定一个字符串,找出其中第一个仅出现一次的字符,若不存在返回-1。Examples:s = "leetcode"return 0.
2016-11-27 11:24:11 345
原创 258. Add Digits
Q:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has
2016-11-27 10:18:05 280 1
原创 136. Single Number
Q:Given an array of integers, every element appears twice except for one. Find that single one.问题:给定一个整数数组,其中除了一个元素仅出现一次,其他每个元素出现了两次。找到这个仅出现一次的数。思路:用异或符“^” ,“^”可以理解为将二进制数的对应位相加且无进位,将数组中所有数依次亦或后,
2016-11-26 21:41:54 318
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人