最近实习生面试因为算法题吃了大亏,之前虽然看了《剑指Offer》,LeetCode也刷了差不多几十道题,但是没有实实在在掌握,现在赶紧补上来,希望还不算太晚!这两天一直在刷Binary Search相关tag的题,暂时把…
标签:LeetCode
[array] leetcode - 39. Combination Sum - Medium
leetcode – 39. Combination Sum – Medium descrition Given a set of candidate numbers (C) (without d…
【Leetcode】491. Increasing Subsequences
Question 491. Increasing Subsequences Given an integer array, your task is to find all the different possible …
339. Nested List Weight Sum
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each elem…
86. 分隔链表
86. 分隔链表 问题 给定一个链表和一个特定值 ,对链表进行分隔,使得所有小于 的节点都在大于或等于的节点之前。 你应当保留两个分区中每个节点的初始相对位置。 示例: 输入: 输出: 解法 新建两个,其中一个保存所有小…
[LEetCode][Python]459. Repeated Substring Pattern
Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple cop…
LeetCode 122. 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…
[LintCode][System Design] Parking Lot
Problem More LeetCode Discussions Design a parking lot. see CC150 OO Design for details. n levels, each level …
Leetcode - Shortest Distance from All Buildings
My code: import java.util.LinkedList; import java.util.Queue; public class Solution { private int row = 0; pri…
[Leetcode]19. 删除链表的倒数第N个节点
题目描述: 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 示例:给定一个链表: 1->2->3->4->5, 和 n = 2. 当删除了倒数第二个节点后,链表变为 1->…
518. 零钱兑换 II
使用滚动数组来优化题目 一般二维 dp 的矩阵可以使用滚动数组来解决问题 DP 规划 dp[i][j]表示的是使用前i个硬币可以凑成j数目的总数. 初始条件 dp[0][0] = 1 表示使用0个硬币, 组成数目0的总数…
64. 最小路径和
class Solution(object): def minPathSum(self, grid): """ :type grid: List[List[int]] :rtype: int """ # 注意初始化 # …