leedcode
文章平均质量分 64
一只菜鸟的学习笔记
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leedcode解析—Python3—Sudoku Solver—hard
题目: Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: 1.Each of the digits 1-9 must occur exactly once in each row. 2.Each of the digits 1-9 must occur exactly once in each colum原创 2021-05-15 02:52:42 · 254 阅读 · 0 评论 -
leedcode解析—Python3—Search in Rotated Sorted Array—Medium
题目: There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], …, n原创 2021-05-10 20:15:38 · 198 阅读 · 0 评论 -
leedcode解析—Python3—Divide Two Integers—Medium
题目 Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. Return the quotient after dividing dividend by divisor. The integer division should truncate toward zero, which means losing its fract原创 2021-05-06 23:52:28 · 184 阅读 · 0 评论 -
leedcode解析—Python3—Regular Expression Matching—hard
题目: Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and ‘✳’ where: ‘.’ Matches any single character. ‘✳’ Matches zero or more of the preceding element. The matching should cover the entire input str原创 2021-04-27 01:04:14 · 155 阅读 · 0 评论 -
leedcode解析—Python3—ZigZag Conversion—medium
题目: The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: 我的思路: 把s拆成给定的行数,依次把s的每个元素加至正确的行中 Runtime: 68 ms(36.82%),Memory Usage: 14.6 MB(24.24%),复杂度:O(len(s)) 我的解答: class Solution: def convert(self, s: str, num原创 2021-04-24 18:14:40 · 159 阅读 · 0 评论 -
leedcode解析—Python3—Longest Common Prefix—easy
题目: 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-04-24 02:08:45 · 216 阅读 · 0 评论 -
leedcode解析—Python3—Add Two Numbers—medium
题目: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two nu原创 2021-04-23 16:25:07 · 339 阅读 · 0 评论 -
leedcode解析—Python3—Multiply Strings—medium
题目: Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to integer directly. 我的思路: 题目非常简单,计算两个原创 2021-04-23 15:34:07 · 121 阅读 · 0 评论 -
leedcode解析—Python3—Longest Substring Without Repeating Characters—medium
题目: Given a string s, find the length of the longest substring without repeating characters. Example : Input: s = “pwwkew” Output: 3 Explanation: The answer is “wke”, with the length of 3. Notice that the answer must be a substring, “pwke” is a subsequence原创 2021-04-23 15:22:20 · 176 阅读 · 0 评论 -
leedcode解析—Python3—Median of Two Sorted Arrays—hard
import numpy as np class Solution: def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: a = np.asarray(nums1) b = np.asarray(nums2) c = np.concatenate((a, b)) d = np.sort(c) if len(d)原创 2021-04-23 10:26:05 · 303 阅读 · 0 评论 -
leedcode解析—Python3—Longest Palindromic Substring—medium
题目: Given a string s, return the longest palindromic substring in s. Example 1: Input: s = “babad” Output: “bab” Note: “aba” is also a valid answer. Example 2: Input: s = “cbbd” Output: “bb” Example 3: Input: s = “a” Output: “a” Example 4: Input: s = “ac”原创 2021-04-22 16:56:19 · 234 阅读 · 1 评论
分享