
数据结构每日一题
人工智能小白菜
如果对博客或者博客中的程序有疑问欢迎和我一起探讨,微信:799330288
展开
-
字符串反转Reverse String
题目https://leetcode.com/problems/reverse-string/Write a function that takes a string as input and returns the string reversed.Example 1:Input: “hello”Output: “olleh”Example 2:Input: “A man, a pla...原创 2019-01-18 23:06:05 · 290 阅读 · 1 评论 -
买股票的最佳时间之二Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one...原创 2019-03-03 14:55:47 · 184 阅读 · 0 评论 -
买卖股票的最佳时间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), ...原创 2019-03-03 14:18:37 · 177 阅读 · 0 评论 -
电话号码的字母组合Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is give...原创 2019-03-02 12:40:50 · 204 阅读 · 0 评论 -
最长共同前缀Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: [“flower”,“flow”,“flight”]Output: “fl...原创 2019-02-12 10:17:21 · 324 阅读 · 0 评论 -
搜索插入位置Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Ex...原创 2019-02-17 20:05:48 · 129 阅读 · 0 评论 -
正则表达式匹配Regular Expression Matching
Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.The ...原创 2019-02-11 18:17:54 · 194 阅读 · 0 评论 -
装最多水的容器Container With Most Water
Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two l...原创 2019-02-11 18:16:07 · 240 阅读 · 0 评论 -
回文数字判断Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExplanation...原创 2019-02-09 21:16:26 · 346 阅读 · 0 评论 -
字符串转数字String to Integer (atoi)
Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this...原创 2019-02-09 14:57:25 · 249 阅读 · 0 评论 -
反转数字Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dealing with an ...原创 2019-02-09 00:50:53 · 151 阅读 · 0 评论 -
找最长无重复子字符串的长度Longest Substring Without Repeating Characters.
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3.Example 2:Input: ...原创 2019-02-07 23:13:47 · 196 阅读 · 0 评论 -
寻找最长回文子字符串Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: “babad”Output: “bab”Note: “aba” is also a valid answer.Example ...原创 2019-02-07 23:11:32 · 219 阅读 · 0 评论 -
数组中两数相加Two Sum
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 have exactly one solution, and you may not use the same e...原创 2019-02-05 16:09:40 · 227 阅读 · 0 评论 -
二叉树最大深度Maximum Depth of BinaryTree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children....原创 2019-01-21 01:45:43 · 234 阅读 · 0 评论 -
跳跃游戏Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you ...原创 2019-03-03 18:07:53 · 238 阅读 · 0 评论