- 博客(28)
- 资源 (4)
- 收藏
- 关注
转载 Java/217. Contains Duplicate 存在重复数字
题目 代码部分一(27ms 30.81%)class Solution { public boolean containsDuplicate(int[] nums) { if(nums == null || nums.length == 0) return false; Map<Integer, In...
2018-09-29 10:12:25 700
转载 Java/205. Isomorphic String 同构字符串
题目 代码部分一(5ms,96.64%)class Solution { public boolean isIsomorphic(String s, String t) { int[] map1 = new int[1000]; int[] map2 = new int[1000]; int...
2018-09-29 10:08:31 616
转载 Java/242. Valid Anagram 有效的字母异位词
题目 代码部分一(6ms 71.86%)class Solution { public boolean isAnagram(String s, String t) { int n1 = s.length(); int n2 = t.length(); if(n1 != n2)return false; ...
2018-09-29 10:01:41 660
转载 Java/409. Longest Palindrome 最长回文串
题目 代码部分一(14ms 63.68%)class Solution { public int longestPalindrome(String s) { int len = s.length(); Map<Character, Integer> map = new HashMap<&g...
2018-09-27 08:54:16 705
转载 Java/202. Happy Number 快乐数
题目 代码部分一(3ms 92.36%)class Solution { public boolean isHappy(int n) { Set<Integer> set = new HashSet<>(); while(n != 1 && !set.contains(n)){ ...
2018-09-25 22:22:01 953
转载 Java/389. Find the Difference 找不同
题目 代码部分一(14ms 36.69%)class Solution { public char findTheDifference(String s, String t) { char res = ' '; Map<Character, Integer> mapS = new HashMap<Characte...
2018-09-25 10:50:20 1022
转载 Java/909. Snakes and Ladders 爬坡和梯子
题目 代码部分二(18ms)class Solution { public int snakesAndLadders(int[][] board) { int n = board.length; int[] b = new int [n*n+1]; boolean flag = true; ...
2018-09-24 17:56:56 1503
转载 Java/ 910. Smallest Rangle II 最小差值 II
题目 代码部分一(16ms)class Solution { public int smallestRangeII(int[] A, int K) { Arrays.sort(A); int len = A.length; int res = A[len-1] - A[0]; ...
2018-09-23 17:46:45 956
转载 Java/908. Smallest Range I 最小差值
题目 代码部分一(6ms)class Solution { public int smallestRangeI(int[] A, int K) { int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; for(int i : A)...
2018-09-23 16:36:04 837
转载 Java/136. Single Number 只出现一次的数字
题目 代码部分一(17ms 26.66%)class Solution { public int singleNumber(int[] nums) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i = 0;...
2018-09-22 18:55:51 739
转载 Java/575. Distribute Candies 分糖果
题目 代码部分一(73ms,82.46%)class Solution { public int distributeCandies(int[] candies) { Map<Integer, Integer> sister = new HashMap<Integer, Integer>(); int...
2018-09-22 18:11:19 655
转载 Java/500. Keyboard Row 键盘行
题目 代码部分一(2ms 99.4%)class Solution { List<String> list = new ArrayList(); public String[] findWords(String[] words) { String frist = "QWERTYUIOPqwertyuiop"; ...
2018-09-21 17:10:46 646
转载 Java/429. N-ary Tree Level Order Traversal N叉树的层序遍历
题目 代码部分一(9ms)class Solution { List<List<Integer>> res = new ArrayList<List<Integer>>(); public List<List<Integer>> levelOrder(Node root) {...
2018-09-20 17:50:37 873
转载 Java/690.Employee Importance 员工的重要性
题目 代码部分(25ms BFS)class Solution { int res = 0; Employee employee; public int getImportance(List<Employee> employees, int id) { findId(employees, id); ...
2018-09-18 11:30:48 809
转载 Java/905.超级回文数 superpalindromes
题目 代码部分一(93ms)class Solution { int res = 0; int[] nums = new int[50]; //存储一个字符串的各个位数 public int superpalindromesInRange(String L, String R) { ...
2018-09-17 19:04:49 1220
转载 905. 按奇偶校验排序数组
题目 代码部分一(18ms)class Solution { public int[] sortArrayByParity(int[] A) { List<Integer> odd = new ArrayList(); // 储存奇数位 List<Integer> even = new Ar...
2018-09-17 15:09:44 1226
转载 Java/907. 子数组的最小值之和
题目 代码部分一(389ms)class Solution { long res = 0; long mod = 1000000007; // 案模, res % mod 得到溢出后的想要的数 ...
2018-09-17 14:56:20 1396
转载 Java/563.Binary Tree Tilt 二叉树的坡度
题目 代码部分(5ms)class Solution { int treeTilt = 0; public int findTilt(TreeNode root) { dfs(root); return treeTilt; } public int dfs(TreeNode node){ ...
2018-09-15 15:29:43 581
转载 Java/501. Find Mode in Binary Search Tree 二叉搜索树中的众数
题目 代码部分一(11ms)class Solution { Map<Integer, Integer> map = new HashMap(); int counter = 0; //计数器,记录众数出现的次数 public int[] findMode(TreeN...
2018-09-13 12:22:04 693
原创 基础算法分析及优化方法(冒泡、选择、插入,盘点面试的时候可能遇到的问题)
一、冒泡算法冒泡算法的一个重点特征是:体现冒泡的过程,大的沉底,小的上浮曾经忽略这个过程,面试被考到了。假定数组下标为[0,1,...,n] 首先从第一个数据开始,与第二个数据相比,若大于第二个数据,则将两个数据的位置进行交换 将指针由第一个数据指向第二个数据,比较第二个数据与第三个数据,如果第二数据比第三个数据大,则交换第二个数据与第三个数据的位置。 以...
2018-09-12 15:32:23 1164
转载 Java/653. Two Sum IV - Input is a BST 两数之和 IV - 输入 BST
题目 代码部分一(592ms)/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * }...
2018-09-11 10:16:10 492
转载 Java/538. Convert BST to Greater Tree 把二叉搜索树转换成累加树
题目 代码部分(17ms)class Solution { int sum = 0; public TreeNode convertBST(TreeNode root) { if(root == null) return null; convertBST(root.right); s...
2018-09-10 18:56:12 593
转载 Java/606. Construct String from Binary Tree 根据二叉树创建字符串
题目 代码部分一(34ms)class Solution { public String tree2str(TreeNode t) { if(t == null) return ""; if(t.left == null && t.right == null) ...
2018-09-09 10:38:44 658
转载 Java/897. Increasing Order Search Tree 递增顺序查找树
题目 代码部分(70ms)class Solution { List<Integer> list = new ArrayList(); public TreeNode increasingBST(TreeNode root) { if(root == null) return root; ...
2018-09-06 10:00:22 1047
转载 Java/896. Monotonic Array 单调数列
题目 代码部分(27ms)class Solution { boolean res = true; public boolean isMonotonic(int[] A) { if(A == null || A.length == 0) return res; boolean index = true;...
2018-09-06 08:55:17 519
转载 101.Symmetric Tree 对称二叉树
题目代码部分一:class Solution { boolean res = true; public boolean isSymmetric(TreeNode root) { if(root == null){ return true; }else if(root.left == null &&am...
2018-09-05 16:19:19 361
转载 112.Path Sum 路径总和
Path Sum I 路径总和 I代码部分一(0ms):class Solution { boolean res = false; public boolean hasPathSum(TreeNode root, int sum) { if(root == null) return false; int coun...
2018-09-04 21:48:15 481
转载 Java/102.Binary Tree Level Order Traversal 二叉树的层次遍历
一、Binary Tree Level Order Traversal I 代码部分一(1ms):class Solution { public List<List<Integer>> levelOrder(TreeNode root) { List<List<Integer>> res = new Arra...
2018-09-03 20:31:36 1245
一个漂亮的用户注册(用户登录)页面 动态效果(与本人博文对应)
2020-03-03
Struts2+Spring+Hibernate+Apache(基本开发完全满足)完整依赖包
2018-08-29
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人