Given a string, find the length of the longest substring T that contains at most k distinct characters. For ex…
分类:LeetCode
Leetcode - Random Pick Index
My code: public class Solution { int[] nums; int result = Integer.MAX_VALUE; Random r; public Solution(int[] n…
LeetCode[3] - LRU Cache
当李特第一次把这题拿出来的时候,我是慌的。 啥是LRU Cache啊? 接下去看吧。 后来,我很天真的来了一个O(n) 的解法,结果果然时间过多。天真解法很简单啊:一个map<key,value>存数值。一个…
[LeetCode] Robot Room Cleaner 扫地机器人
Given a robot cleaner in a room modeled as a grid. Each cell in the grid can be empty or blocked. The r…
LeetCode | Combination Sum II(元素的和---2)
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C&nb…
[算法总结] 17 题! BAT面试涉及的链表题都在这里了
本文首发于我的个人博客:尾尾部落 链表是面试过程中经常被问到的,这里把剑指offer 和 LeetCode 中的相关题目做一个汇总,方便复习。 1. 在 O(1) 时间删除链表节点 题目描述:给定单向链表的头指针和一个节…
[LeetCode By Go 40]599. Minimum Index Sum of Two Lists
题目 Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restau…
[LeetCode] Product of Array Except Self 除本身之外的数组之积
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal …
[LeetCode] Hamming Distance 汉明距离
The Hamming distance between two integers is the number of positions at which the correspondi…
[LeetCode] Range Addition II 范围相加之二
Given an m * n matrix M initialized with all 0’s and several update operations. Op…
LeetCode | Best Time to Buy and Sell Stock III(股票购买抛售问题III)
Say you have an array for which the ith element is the price of a given stock on day i. Design …
LeetCode | Remove Duplicates from Sorted List(删除链表中重复的数据)
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, G…