![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode JAVA之路
文章平均质量分 52
MR_LUXY
这个作者很懒,什么都没留下…
展开
-
Leetcode 138 和 Java的深拷贝
今天做到leetcode的138题,题目是返回一个拥有随机指针的链表的深拷贝。由于我是用Java做的,先深入复习一下Java的对象拷贝机制。Java类型和浅拷贝Java的类型分为值类型和引用类型。其中值类型包括所有的基本类型,char, boolean, int, double, float, long, short, byte。其他的类、接口、枚举和数组等都是引用类型。...原创 2020-01-30 19:24:20 · 382 阅读 · 0 评论 -
最长回文子串 leetcode 05 DP解法
找出最长回文子串,马上想到了用DP,用 dp[ i ][ j ] = 1表示s[ i ]----s[ j ]是一个回文串 dp[ i ][ j ] = 0就表示s[ i ]---[ j ]为非回文,方程可以表示为 if(s[ i ]==s[ j ]) dp[ i ][ j ] = dp[ i+1 ][ j-1 ],其实也可以明确为,前一个子串是回文串的,当前才继续做判断,否则直接不管,可原创 2015-01-26 14:44:17 · 1523 阅读 · 0 评论 -
leetcode: Happy Number
题意:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of th原创 2015-04-22 12:38:04 · 1058 阅读 · 0 评论 -
leetcode:Populating Next Right Pointers in Each Node
一道DFS的题目,题意如下:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 1原创 2015-04-08 00:55:29 · 506 阅读 · 0 评论 -
leetcode:Path Sum II
又一道DFS题,题意如下:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5原创 2015-04-08 01:51:55 · 518 阅读 · 0 评论 -
leetcode:sudoku solver
sudoku solver原创 2015-04-15 14:52:07 · 527 阅读 · 0 评论 -
leetcode: Remove Linked List Elements(java)
Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special than原创 2015-04-24 14:42:59 · 797 阅读 · 0 评论 -
leetcode: Reverse Linked List(java)
哎呀,糟了,leetcode又有easy题了,好久没上,直接在网站上A了。题目就是把一个链表倒过来。。。public ListNode reverseList(ListNode head) { if(head == null)return null; ListNode preNode = null; ListNode curNo原创 2015-05-05 11:49:55 · 714 阅读 · 0 评论 -
leetcode:Isomorphic Strings (java)
记录一道hashtable的题,用两次互相的字符(s[i])到字符(t[i])映射记录,然后按照映射还原比较就可以判断是否相同,开始以为只有字母,后来发现是ascii码表长度的alphabet才可以~public static boolean isIsomorphic(String s, String t) { char[] alph1 = new char[128];原创 2015-05-05 12:23:43 · 793 阅读 · 0 评论 -
leetcode majority element
题目:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority原创 2015-02-14 20:33:08 · 463 阅读 · 0 评论 -
leetcode: Triangle
题意:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3原创 2015-02-16 00:20:08 · 540 阅读 · 0 评论 -
两道用到二分法的math题:Sqrt(x) && Pow(x, n)
第一题求一个int数的平方根,返回值也是int,开始直接原创 2014-11-17 00:32:57 · 609 阅读 · 0 评论 -
链表的归并排序
今天做了链表的冒泡排序和归并排序,原创 2014-11-12 00:30:18 · 631 阅读 · 0 评论 -
LRUCache
今天A了两题,先来这道最不最近使用的内存,饿= =。原题描述是这样的:原创 2014-11-13 01:31:12 · 377 阅读 · 0 评论 -
leetcode(2)--String reverse
这是第一个比较麻烦的题目,原创 2014-11-11 09:53:31 · 688 阅读 · 0 评论 -
链表的冒泡排序
最简单的冒泡排序,多年没写,重新复习了一下原创 2014-11-11 15:03:41 · 736 阅读 · 0 评论 -
Evaluate Reverse Polish Notation--逆波兰式求值
这个太简单了,用一个栈搞定。不过很久没有写代码,忘记了一些java的基础,比如switch语句差点原创 2014-11-13 01:43:28 · 459 阅读 · 0 评论 -
Single Number & Single Number II
今天做了蛮多题,这两道找single number 的原创 2014-11-14 01:35:47 · 494 阅读 · 0 评论 -
Reorder List
题意如下:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reord原创 2014-11-14 01:39:14 · 366 阅读 · 0 评论 -
Linked List Cycle
这两道题也用到了快慢指针,前一题原创 2014-11-15 16:54:17 · 478 阅读 · 2 评论 -
Max product subarray
这几天为了准备wap的tech interview,无意间看到了leetcode OJ原创 2014-11-11 01:15:26 · 606 阅读 · 0 评论