LeetCode
文章平均质量分 79
Soleil-luo
做最优的自己
展开
-
LeetCode 1.Two Sum - 和为target的数组索引位置(JAVA)
题目链接https://leetcode.com/problems/two-sum/description/题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would h...原创 2018-04-09 21:50:39 · 226 阅读 · 0 评论 -
LeetCode 2.Add Two Numbers-两个链表相加(JAVA)
题目链接https://leetcode.com/problems/add-two-numbers/description/题目理解:给定两个链表,存储整形数据,返回相加的结果。第一个节点表示整数的个位,对应位置上值进行相加操作,中间涉及相加大于等于10时的进位。需要会对链表的头结点,下一位及取值,存值,数组转换成链表存储等操作。第一种解法-常规思路优点:思路明了缺点:运行速度慢,耗时思路及源码如...原创 2018-04-16 11:47:43 · 1090 阅读 · 0 评论 -
LeetCode 125. Valid Palindrome-回文字符串判断
题目链接:https://leetcode.com/problems/valid-palindrome/description/题目理解题目的意思是,判断一个字符串是否是回文字符串,只考虑字母和数字,忽略大小写。此处将空字符串定义为回文字符串,即如果一个字符串只有非字母和非数字,也是回文字符串。eg:!%^^^^%%,是一个回文字符串。思路及实现使用JVA中char的工具类Character进行字...原创 2018-04-16 22:38:22 · 323 阅读 · 0 评论 -
LeetCood 21. Merge Two Sorted Lists-合并两个有序的链表(JAVA)
题目理解Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-&...原创 2018-04-17 21:38:47 · 249 阅读 · 1 评论 -
LeetCode 88. Merge Sorted Array-合并两个有序数组(JAVA)
题目理解Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additio...原创 2018-04-18 21:00:11 · 1515 阅读 · 0 评论 -
LeetCode 144. Binary Tree Preorder Traversal-二叉树的前序遍历(JAVA迭代及递归方法实现)
题目解读Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,2,3].Note: Recursive solution is trivial, c...原创 2018-04-19 21:02:15 · 937 阅读 · 0 评论