算法与数据结构
文章平均质量分 59
算法与数据结构
wuli鲲鲲
化被動為主動。
展开
-
【LeetCode】number 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.A subarray is a contiguous part of an array.Example 1:Input: nums = [-2,1,-3,4,-1,2,1,-5,4]Output: 6Explanation原创 2021-09-08 23:09:14 · 83 阅读 · 0 评论 -
【LeetCode】number 27:Remove Element 移除元素
问题Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed.Since it is impossible to change the length of the array in some languages, you must instead have the resu原创 2021-08-11 23:31:20 · 66 阅读 · 0 评论 -
【LeetCode】number 26: Remove Duplicates from Sorted Array 有序数组中去除重复项
问题Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same.Since it is impossible to change the length of the ar原创 2021-08-09 23:58:00 · 186 阅读 · 0 评论 -
【LeetCode】number 21:Merge Two Sorted Lists 混合插入有序链表
问题Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists.Example 1:Input: l1 = [1,2,4], l2 = [1,3,4]Output: [1,1,2,3,4,4]Example 2:Input: l1 = [], l2 = []Output:原创 2021-08-09 23:29:16 · 57 阅读 · 0 评论 -
【LeetCode】number 20: Valid Parentheses 验证括号
问题Given a string s containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type ofbrackets.【左括号必须用相同类型的右括号闭合】Open brackets must be clo原创 2021-08-05 23:56:37 · 64 阅读 · 0 评论 -
【LeetCode】number 14: 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: strs = [“flower”,“flow”,“flight”]Output: “fl”Example 2:Input: strs = [“dog”,“racecar”原创 2021-08-05 00:07:41 · 61 阅读 · 0 评论 -
[LeetCode] number 13: Roman to Integer 罗马数字转化成整数
问题Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol: ValueI: 1V: 5X: 10L: 50C: 100D: 500M: 1000For example, 2 is wr原创 2021-08-04 23:33:35 · 79 阅读 · 0 评论 -
【LeetCode】number 9: Palindrome Number 验证回文数字
问题Given an integer x, return true if x is palindrome integer.An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.Example 1:Input: x = 121Output: trueExample 2:Input: x = -121Outp原创 2021-08-03 23:53:05 · 115 阅读 · 0 评论 -
【LeetCode】number 7: Reverse Integer 翻转整数
一、问题给定一个 32 位有符号整数,将整数中的数字进行反转Example 1:Input: x = 123Output: 321Example 2:Input: x = -123Output: -321Example 3:Input: x = 120Output: 21Example 4:Input: x = 0Output: 0二、解析1、需要注意“溢出”,由于x是一个整型数,所以x的范围也应该在 -2147483648~2147483647 之间,而x的反原创 2021-08-03 23:21:34 · 85 阅读 · 0 评论 -
【LeetCode】number 1: Two Sum两数之和
一、问题Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the an原创 2021-07-01 13:00:20 · 87 阅读 · 0 评论