Given an absolute path for a file (Unix-style), simplify it. For example, path = “/home/”, => &…
分类:LeetCode
[LeetCode By Go 90]643. Maximum Average Subarray I
题目 Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximu…
[LeetCode] Smallest Rectangle Enclosing Black Pixels 包含黑像素的最小矩阵
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black…
[LeetCode] Kth Smallest Element in a Sorted Matrix 有序矩阵中第K小的元素
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth sma…
LeetCode 098 Validate Binary Search Tree
题目描述 Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as foll…
【leetcode】91. Decode Ways A-Z的字母表示1-26的数字,反向破解多少种字符串的可能性
1. 题目 A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A&…
【leetcode】55. Jump Game 数组跳转是否可以到达末节点
1. 题目 Given an array of non-negative integers, you are initially positioned at the first index of the array. E…
算法学习——DP(二)
LCS问题(最长公共子序列) 上一篇文章 所有代码和markdown在chux0519/algs同步更新。 计算LCS长度 递归解法 LCS问题是具有最优子结构的。 假设长度为m的字符串X[0..m-1]和长度为n的字符…
21. 合并两个有序链表(Swift版)
一、题目 将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例: 输入:1->2->4, 1->3->4 输出:1->1->2->3…
[LeetCode] Minimum Depth of Binary Tree
链接:https://leetcode.com/problems/minimum-depth-of-binary-tree/description/ 难度:Easy 题目:111. Minimum Depth of Bi…
2018-09-26 137. Single Number II
题意:给你一个vector数组,只有一个数出现一次,其余的数都出现三次,返回那个出现一次的数。要求:时间复杂度O(N),空间复杂度O(1)。 背景知识: 异或操作规则:相同位相同元素异或后为0,相同位不同元素异或后为1.…
Leetcode - Trapping Rain Water II
My code: public class Solution { private class Cell { int x; int y; int h; Cell(int x, int y, int h) { this.x …