leetcode
文章平均质量分 57
longma8520
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[leetcode]367. Valid Perfect Square
Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Return原创 2017-03-25 23:54:58 · 309 阅读 · 0 评论 -
[leetcode]345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "hello", return "holle". Example 2: Given s = "leetcode", return "leotcede". Note原创 2017-03-25 23:46:33 · 438 阅读 · 0 评论 -
[leetcode]198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house原创 2017-03-25 23:01:23 · 293 阅读 · 0 评论 -
[leetcode]235. Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw原创 2017-03-25 21:21:08 · 347 阅读 · 0 评论 -
[leetcode]107. Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree [3,9,20,null,null,1原创 2017-03-25 16:08:59 · 379 阅读 · 0 评论 -
[leetcode]21.Merge Two Sorted Lists
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. 连接两个有序链表,链接后依然有序。 遍历两个链表,依次讲较小节点加入新的链表当中。 /** * Defini原创 2017-03-25 20:43:17 · 339 阅读 · 0 评论 -
[leetcode]53. Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1]原创 2017-03-24 13:29:17 · 286 阅读 · 0 评论 -
[leetcode]83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 删除重复的节点 一开原创 2017-03-23 23:41:13 · 332 阅读 · 0 评论 -
[leetcode]121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),原创 2017-03-23 15:51:09 · 548 阅读 · 0 评论 -
[leetcode]405. Convert a Number to Hexadecimal
Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: All letters in hexadecimal (a-f) must be in lowercase.The hexade原创 2017-03-23 14:59:25 · 364 阅读 · 0 评论 -
[leetcode]108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 每次递归取数组的中间值作为根节点,则左子树的根为(left,mid-1)/2对应的值,右子树根为(mid+1,right)/2 /** * Definition for a binary t原创 2017-03-23 14:07:48 · 446 阅读 · 0 评论 -
[leetcode]415. Add Strings
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is Both num1 and num2 contains only digits 0-9.原创 2017-03-23 12:21:32 · 549 阅读 · 0 评论 -
[leetcode]286. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm sho原创 2017-03-22 23:00:55 · 478 阅读 · 0 评论 -
[leetcode]205. Isomorphic Strings
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with anot原创 2017-03-29 23:51:01 · 307 阅读 · 0 评论 -
[leetcode]234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 判断单链表是否为回文链表 此题用栈来做将非常简单,第一次遍历将节点入栈,第二次遍历判断是否为回文 public class Solution {原创 2017-03-30 12:36:08 · 319 阅读 · 0 评论 -
[leetcode]219. Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is a原创 2017-03-30 13:14:24 · 451 阅读 · 0 评论
分享