![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode算法
文章平均质量分 62
BeLeaderOfMyLife
专一iOS平台终端开发以自己有限的生命奉献给无穷的编程时光热爱生活更热爱编程
展开
-
[leetcode]53 Ugly Number
题目链接:https://leetcode.com/problems/ugly-number/ Runtime:8ms1、问题Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3原创 2015-09-06 11:27:54 · 350 阅读 · 0 评论 -
[leetcode]41 Climbing Stairs
题目链接:https://leetcode.com/problems/climbing-stairs/ Runtimes:2ms1、问题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 distinc原创 2015-03-31 10:59:54 · 445 阅读 · 0 评论 -
[leetcode]40 Remove Nth Node From End of List
题目链接:https://leetcode.com/problems/remove-nth-node-from-end-of-list/ Runtimes:11ms1、问题Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list原创 2015-03-31 10:44:06 · 439 阅读 · 0 评论 -
[leetcode]37 Roman to Integer
题目链接:https://leetcode.com/problems/roman-to-integer/ Runtimes:57ms1、问题Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.2、分析简单的模式匹配过程,数字参考了这篇文原创 2015-03-31 09:41:33 · 392 阅读 · 0 评论 -
[leetcode]36 ZigZag Conversion
题目链接:https://leetcode.com/problems/zigzag-conversion/ Runtimes:40ms1、问题The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pat原创 2015-03-30 22:34:31 · 365 阅读 · 0 评论 -
[leetcode]33 Palindrome Number
题目链接:https://leetcode.com/problems/palindrome-number/ Runtimes:131ms1、问题Determine whether an integer is a palindrome. Do this without extra space.2、分析删除回文,传统思路是按照顺序将数字存入数组,然后进行字符串回文检查。但是问题要求不要有额外空间,想了原创 2015-03-30 15:21:00 · 435 阅读 · 0 评论 -
[leetcode]35 Reverse Integer
文章链接:https://leetcode.com/problems/reverse-integer/ Runtimes:14ms1、问题Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321Have you thought about this? Here原创 2015-03-30 21:46:30 · 412 阅读 · 0 评论 -
[leetcode]34 String to Integer (atoi)
题目链接:https://leetcode.com/problems/string-to-integer-atoi/ Runtimes:15ms1、问题Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challen原创 2015-03-30 21:32:00 · 431 阅读 · 0 评论 -
[leetcode]26 Minimum Depth of Binary Tree
题目链接:https://leetcode.com/problems/minimum-depth-of-binary-tree/ Runtimes:16ms1、问题Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from th原创 2015-03-11 14:17:38 · 445 阅读 · 0 评论 -
[leetcode]25 Number of 1 Bits
题目链接:https://leetcode.com/problems/number-of-1-bits/ Runtimes:10ms1、问题Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight). For原创 2015-03-11 13:55:27 · 508 阅读 · 0 评论 -
[leetcode]24 Path Sum II
题目链接:https://leetcode.com/problems/path-sum-ii/ Runtimes:93ms1、问题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 be原创 2015-03-11 13:45:32 · 389 阅读 · 0 评论 -
[leetcode]32 Length of Last Word
题目链接:https://leetcode.com/problems/length-of-last-word/ Runtimes:4ms1、问题Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the st原创 2015-03-28 16:18:50 · 390 阅读 · 0 评论 -
[leetcode]38 Longest Common Prefix
题目链接:https://leetcode.com/problems/longest-common-prefix/ Runtimes:8ms1、问题Write a function to find the longest common prefix string amongst an array of strings.2、分析简单的题目,查找字符串集合中最长前缀。3、小结string函数中subs原创 2015-03-31 10:09:28 · 411 阅读 · 0 评论 -
[leetcode]39 Valid Parentheses
题目链接:https://leetcode.com/problems/valid-parentheses/ Runtimes:3ms1、问题Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets原创 2015-03-31 10:39:23 · 382 阅读 · 0 评论 -
[leetcode]45 Add Binary
题目链接:https://leetcode.com/problems/add-binary/ Runtimes:6ms1、问题Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.2、分析从尾部开始相加,^用来进行不进原创 2015-04-02 13:58:22 · 472 阅读 · 0 评论 -
[leetcode]52 Add Digits
题目链接:https://leetcode.com/problems/add-digits/ runtime:8ms1、问题Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the proces原创 2015-09-06 10:35:01 · 438 阅读 · 0 评论 -
[leetcode]51 Delete Node in a Linked List
题目链接:https://leetcode.com/problems/delete-node-in-a-linked-list/ runtime:16ms1、问题Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed th原创 2015-09-06 10:05:30 · 606 阅读 · 0 评论 -
[leetcode]51 Two Sum
题目链接:https://leetcode.com/problems/two-sum/ Runtimes:57ms1、问题Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of原创 2015-04-08 19:43:58 · 462 阅读 · 0 评论 -
[leetcode]49 Remove Element
题目链接:https://leetcode.com/problems/remove-element/ Runtimes:6ms1、问题Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be change原创 2015-04-07 15:14:13 · 372 阅读 · 0 评论 -
[leetcode]48 Binary Tree Right Side View
题目链接:https://leetcode.com/problems/binary-tree-right-side-view/ Runtimes:9ms1、问题Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see order原创 2015-04-07 13:32:35 · 479 阅读 · 0 评论 -
[leetcode]47 House Robber
题目链接:https://leetcode.com/problems/house-robber/ Runtimes:3ms1、问题You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constra原创 2015-04-07 12:47:35 · 421 阅读 · 0 评论 -
[leetcode]50 Count and Say
题目链接:https://leetcode.com/problems/count-and-say/ Runtimes:12ms1、问题The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, …1 is read off as “one 1” or 1原创 2015-04-07 16:03:22 · 562 阅读 · 0 评论 -
[leetcode]42 Merge Two Sorted Lists
题目链接:https://leetcode.com/problems/merge-two-sorted-lists/ Runtimes:17ms1、问题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原创 2015-04-01 12:11:30 · 403 阅读 · 0 评论 -
[leetcode]43 Remove Duplicates from Sorted Array
题目链接:https://leetcode.com/problems/remove-duplicates-from-sorted-array/ Runtimes:37ms1、问题Given a sorted array, remove the duplicates in place such that each element appear only once and return the new原创 2015-04-01 15:28:41 · 401 阅读 · 0 评论 -
[leetcode]44 Balanced Binary Tree
题目链接:https://leetcode.com/problems/balanced-binary-tree/ Runtimes:21ms1、问题Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary原创 2015-04-02 14:05:05 · 588 阅读 · 0 评论 -
[leetcode]46 Plus One
题目链接:https://leetcode.com/problems/plus-one/ Runtimes:4ms1、问题Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant原创 2015-04-02 14:33:30 · 458 阅读 · 0 评论 -
[leetcode]31 Symmetric Tree
题目链接:https://leetcode.com/problems/symmetric-tree/ Runtimes:8ms1、问题Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmet原创 2015-03-28 15:36:53 · 386 阅读 · 0 评论 -
[leetcode]23 Path Sum
题目链接:https://leetcode.com/problems/path-sum/ Runtimes:201、问题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 gi原创 2015-03-11 12:16:57 · 523 阅读 · 0 评论 -
[leetcode]12 Excel Sheet Column Number
题目链接:https://oj.leetcode.com/problems/excel-sheet-column-number/ Runtimes:16ms1、问题Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its correspondi原创 2015-03-05 15:56:24 · 457 阅读 · 0 评论 -
[Leetcode]11 Rotate Array
Rotate Array题目连接:https://oj.leetcode.com/problems/rotate-array/ Runtimes:26ms1、问题Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is原创 2015-03-05 12:00:24 · 532 阅读 · 0 评论 -
leetcode10:Distinct Subsequences
Distinct Subsequences题目连接:https://oj.leetcode.com/problems/distinct-subsequences/runtimes:38ms一、问题 Given a string S and a string T, count the number of distinct subsequences of原创 2015-01-25 11:15:28 · 497 阅读 · 0 评论 -
leetcode9:Next Permutation
Next Permutation 题目链接:https://oj.leetcode.com/problems/next-permutation/runtimes:17ms一、问题Implement next permutation, which rearranges numbers into the lexicographically next greater原创 2015-01-24 10:19:22 · 527 阅读 · 0 评论 -
leetcode6:Search in Rotated Sorted Array
Search in Rotated Sorted Array题目连接:https://oj.leetcode.com/problems/search-in-rotated-sorted-array/runtimes:7ms一、问题 Suppose a sorted array is rotated at some pivot unknown to y原创 2015-01-22 19:30:52 · 508 阅读 · 0 评论 -
leetcode7:Binary Tree Level Order Traversal II
Binary Tree Level Order Traversal II 题目连接:https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/runtimes:9ms一、问题 Given a binary tree, return the bottom-up level o原创 2015-01-23 09:36:13 · 438 阅读 · 0 评论 -
leetcode8:Factorial Trailing Zeroes
Factorial Trailing Zeroes 题目连接:https://oj.leetcode.com/problems/factorial-trailing-zeroes/runtimes:7ms一、问题 Given an integer n, return the number of trailing zeroes in n!.原创 2015-01-23 10:31:00 · 648 阅读 · 0 评论 -
leetcode5:Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal题目连接:https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/runtimes:84ms一、问题Given preorder and原创 2015-01-22 16:26:33 · 535 阅读 · 0 评论 -
leetcode:Sudoku Solver
Sudoku Solver题目连接:https://oj.leetcode.com/problems/sudoku-solver/runtimes:15ms一、问题Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by原创 2015-01-22 10:20:51 · 477 阅读 · 0 评论 -
Leetcode:Maximum Subarray
Maximum Subarray题目链接:https://oj.leetcode.com/problems/maximum-subarray/runtimes:12ms一、问题 Find the contiguous subarray within an array (containing at least one number) which has the原创 2015-01-19 23:43:22 · 460 阅读 · 0 评论 -
leetcode:Reverse Words in a String
Reverse Words in a String原题连接:https://oj.leetcode.com/problems/reverse-words-in-a-string/runtimes:9ms一、实例 如字符串:“ hello world ! ”,输出应该为 “!world hello”。二、分析输入一个字符串,将其中的单原创 2015-01-16 11:27:06 · 714 阅读 · 0 评论 -
[leetcode]15 Compare Version Numbers
题目链接:https://oj.leetcode.com/problems/compare-version-numbers/ Runtimes:2ms1、问题ompare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, oth原创 2015-03-06 20:41:03 · 345 阅读 · 0 评论