Medium 一开始直接clone数组居然TLE, 后来初始化的时候把shortest初始化为map.size()肯定有问题的,因为dict里面是允许duplicate的,所有你map.size()有可能是小于单词最大距…
标签:LeetCode
LeetCode刷题之Reverse Integer
Problem Reverse digits of an integer. Example:x = 123, return 321 Example:x = -123, return -321 Note: The inpu…
leetcode刷题笔记(2)(python)
344 Reverse String题意:给出一个字符串对字符串进行翻转(reverse)思路:直接使用切片函数进行翻转(网上看到的,具体怎么使用有点迷)[::-1]代码:`class Solution(object):…
LeetCode #807. Max Increase to Keep City Skyline python
Question In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located ther…
[LeetCode] 4. Median of Two Sorted Arrays 题解
问题描述 两个有序的数组 nums1 和 nums2 ,它们的数组长度分别为 m 和 n。要求找到这两个数组的中位数,且总体的时间复杂度必须为 。 假设 nums1 和 nums2 都不为空。 例 1: nums1 = …
Leetcode之66-加一(Plus One)
前言 个人网站 公众号: 北京程序猿, 网站 : https://yaml.vip 算法题 题干 给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。 最高位数字存放在数组的首位, 数组中每个元素只存储一个…
LeetCode | 2. Add Two Numbers
题目链接:https://leetcode.com/problems/add-two-numbers/ 题目难度:Medium 题目描述: You are given two non-empty linked lists…
Leetcode 91. Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’…
LeetCode刷题之Remove Duplicates from Sorted List
Problem Given a sorted linked list, delete all duplicates such that each element appear only once. For example…
[array] leetCode-27. Remove Element - Easy
27. Remove Element – Easy descrition Given an array and a value, remove all instances of that value in-p…
040 Combination Sum II[M]
1 题目描述 Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C …
2016.9.12; Leetcode 292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one…