![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
ZoJane
生不带来,死不带走。
展开
-
leetcode500键盘行(c语言实现)
源代码:/** * Return an array of size *returnSize. * Note: The returned array must be malloced, assume caller calls free(). */int which(char ch){ if(ch=='q'||ch=='w'||ch=='e'||ch=='r'|...原创 2019-03-21 09:07:26 · 353 阅读 · 0 评论 -
leetcode451. 根据字符出现频率排序(JAVA)(hashmap)
my solution:class Solution { public String frequencySort(String s) { Map<Character,Integer> map=new HashMap<>(); List<Character> ret=new ArrayList<C...原创 2019-04-05 20:05:46 · 592 阅读 · 0 评论 -
leetcode202快乐数(JAVA)(hashset)
class Solution { public boolean isHappy(int n) { if(n==1||n==-1) return true; HashSet<Integer>h=new HashSet<Integer>(); int m=0...原创 2019-03-31 23:00:13 · 325 阅读 · 0 评论 -
leetcode513找树左下角的值(JAVA实现)
实际上也是广度优先搜索,不过有了一点改变,先右在左,等于镜像的广度优先遍历/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { v...原创 2019-03-24 12:32:51 · 250 阅读 · 0 评论 -
leetcode109有序链表转换二叉搜索树(JAVA实现)(前序遍历二叉树)
解答:递归前序遍历/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } *//** * Definition for a binary tree ...原创 2019-03-23 20:58:08 · 327 阅读 · 0 评论 -
leetcode1002查找常用字符(Java)(hashmap)
class Solution { public List<String> commonChars(String[] A) { Map<Character,Integer> map=new HashMap<>(); for(char c:A[0].toCharArray()){ map.put(...原创 2019-04-03 22:59:58 · 333 阅读 · 0 评论 -
leetcode230二叉搜索树中第K小的元素(JAVA实现)(我的奇妙solution)
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { ...原创 2019-03-26 15:48:07 · 206 阅读 · 0 评论 -
leetcode557反转字符串中的单词 III(字符处理)(JAVA实现)
class Solution { public String reverseWords(String s) { String words[]=s.split(" "); StringBuilder res=new StringBuilder();//要加()号 for(String word:words) res...原创 2019-03-22 22:44:43 · 396 阅读 · 0 评论 -
leetcode559N叉树的最大深度(java实现)
/*// Definition for a Node.class Node { public int val; public List<Node> children; public Node() {} public Node(int _val,List<Node> _children) { val = _val;...原创 2019-03-21 17:02:55 · 203 阅读 · 0 评论 -
leetcode94.二叉树的前序遍历(JAVA实现)
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { p...原创 2019-03-21 16:18:00 · 216 阅读 · 0 评论 -
leetcode.136只出现一次的数字(JAVA)(hashmap)
class Solution { public int singleNumber(int[] nums) { Map<Integer,Integer>counts=new HashMap<Integer, Integer>(); for(int num:nums) { if(counts....原创 2019-03-28 21:52:53 · 321 阅读 · 0 评论