LeetCode
记录在LeetCode上做的题
remo0x
no one
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【LeetCode】初级算法:动态规划
1. 爬楼梯用时:4msclass Solution { public int climbStairs(int n) { if(n==1) return 1; if(n==2) return 2; int[] num=new int[n]; num[0]=1; num[1]=2; for...原创 2018-08-21 21:51:35 · 600 阅读 · 0 评论 -
【LeetCode】初级算法:排序和搜索
1. 合并两个有序数组用时:5msclass Solution { public void merge(int[] nums1, int m, int[] nums2, int n) { int i=0,j=0,temp1,temp2; while(j<n&&i<(m+j)){ // 找到插入点 ...原创 2018-07-08 17:39:38 · 395 阅读 · 0 评论 -
【LeetCode】初级算法:树
1. 二叉树的最大深度用时:0msclass Solution { public int maxDepth(TreeNode root) { // 返回左右子树深度的最大值,再加1 if(root!=null){ return Math.max(maxDepth(root.left),maxDepth(root.right...原创 2018-05-31 10:44:11 · 450 阅读 · 0 评论 -
【LeetCode】初级算法:链表
题目可以在LeetCode查看1. 删除链表的结点用时:0msclass Solution { public void deleteNode(ListNode node) { node.val=node.next.val; node.next=node.next.next; }}2. 删除链表的倒数第N个节点...原创 2018-05-11 22:46:13 · 481 阅读 · 0 评论 -
【LeetCode】初级算法:字符串
题目可以在LeetCode查看1. 反转字符串用时:3msclass Solution { public String reverseString(String s) { // 用时:4ms // StringBuilder sb=new StringBuilder(); // for(int i=s.length()...原创 2018-05-10 18:21:15 · 565 阅读 · 0 评论 -
【LeetCode】初级算法:数组
HashMapHashMap是基于Hash表的Map接口实现的,它提供所有可选的Map操作,并且允许多个null值和一个null键。HashMap不保证元素的有序,尤其是不保证随着时间的推移元素会保持之前的顺序。HashMap除了以下两点之外,其它方面和Hashtable大致相当非同步的(unsynchronized)允许null键值假设hash函数在buckets之间正...原创 2018-05-09 22:37:20 · 946 阅读 · 0 评论