![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
v_v...
这个作者很懒,什么都没留下…
展开
-
LeetCode 53 Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanati...原创 2018-08-10 21:14:46 · 102 阅读 · 0 评论 -
125 Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid palindrome.Examp...原创 2018-08-25 15:45:01 · 126 阅读 · 0 评论 -
136. Single Number
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us...原创 2018-08-25 16:31:01 · 97 阅读 · 0 评论 -
LeetCode . MySql 相关题
175. Combine Two TablesTable: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+--...原创 2018-09-02 19:36:59 · 145 阅读 · 0 评论 -
LeetCode.189 Rotate Array
Given an array, rotate the array to the right by k steps, where k is non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the right: [7,1...原创 2018-09-05 09:29:53 · 151 阅读 · 0 评论 -
LeetCode.Bash 相关题
193. Valid Phone NumbersGiven a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.You may assume that a valid ph...原创 2018-09-08 17:11:46 · 204 阅读 · 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...原创 2018-09-08 20:47:40 · 150 阅读 · 0 评论 -
LeetCode ---202. 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 the squares o...原创 2018-09-09 21:14:06 · 145 阅读 · 0 评论 -
LeetCode ---204. Count Primes
Count the number of prime numbers less than a non-negative number, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.思路:利用厄拉多塞筛法。具体操作:先将 ...转载 2018-09-09 22:22:09 · 131 阅读 · 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 another ...原创 2018-09-16 10:17:09 · 132 阅读 · 0 评论 -
LeetCode 206. Reverse Linked List
Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursi...原创 2018-09-16 10:46:23 · 139 阅读 · 0 评论 -
LeetCode 225. Implement Stack using Queues && 232. Implement Queue using Stacks
LeetCode 225. Implement Stack using QueuesImplement the following operations of a stack using queues.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top()...原创 2018-09-19 18:10:01 · 170 阅读 · 0 评论 -
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 (i.e., buy one and sell one share of the stock),...原创 2018-08-25 10:06:02 · 103 阅读 · 0 评论 -
LeetCode 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf is a node with no children.Example:...原创 2018-08-13 17:05:08 · 112 阅读 · 0 评论 -
LeetCode 58 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defin...原创 2018-08-10 21:23:03 · 96 阅读 · 0 评论 -
Leetcode - Merge Two Sorted List
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-08-06 21:20:17 · 142 阅读 · 0 评论 -
LeetCode 67 - Add Binary
Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = "11", b = "1"Output: "100"Exam...转载 2018-08-11 10:36:41 · 136 阅读 · 0 评论 -
LeetCode-69 Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only...原创 2018-08-11 11:31:51 · 148 阅读 · 0 评论 -
LeetCode - 70 Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive...原创 2018-08-11 17:24:38 · 107 阅读 · 0 评论 -
LeetCode 88 Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume tha...原创 2018-08-11 21:44:06 · 80 阅读 · 0 评论 -
LeetCode - Same Tree 100
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example ...原创 2018-08-12 12:01:55 · 175 阅读 · 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,15,7...原创 2018-08-12 18:08:29 · 122 阅读 · 0 评论 -
LeetCode 101. Symmetric Tree (对称二叉树) 108. Convert Sorted Array To BST(二叉搜索树)
101. Symmetric Tree (对称二叉树)Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \...原创 2018-08-13 11:15:37 · 99 阅读 · 0 评论 -
LeetCode 110 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never diff...原创 2018-08-13 11:38:46 · 119 阅读 · 0 评论 -
LeetCode 111. Minimum Depth of Binary
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no childre...原创 2018-08-13 16:39:09 · 120 阅读 · 0 评论 -
234. Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueFollow up:Could you do it in O(n) time a...原创 2018-09-23 10:29:24 · 144 阅读 · 0 评论