[LeetCode] N-ary Tree Postorder Traversal N叉树的后序遍历
Given an n-ary tree, return the postorder traversal of its nodes' values.For example, given a 3-ary tree:Return its postorder traversal as: [5,6,3,2,4...
[算法][LeetCode]Search a 2D Matrix——二维数组的二分查找
题目要求Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorte...
LeetCode 32 Longest Valid Parentheses (C,C++,Java,Python)
Problem: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For...
[LeetCode] Find the Difference
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a...
LeetCode "Longest Substring with At Most K Distinct Characters"
A simple variation to "Longest Substring with At Most Two Distinct Characters". A typical sliding window problem.class Solution {public: int length...
leetCode70.爬楼梯
假设你正在爬楼梯。需要 n 阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?注意:给定 n 是一个正整数。示例 1:输入: 2输出: 2解释: 有两种方法可以爬到楼顶。1. 1 阶 + 1 阶2. 2 阶示例 2:输入: 3输出: 3解释: 有三种方法可以...
LeetCode:Minimum Path Sum(网格最大路径和)
题目链接Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its pa...
【leetcode 简单】第二十题 合并两个有序数组
给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组。说明:初始化 nums1 和 nums2 的元素数量分别为 m 和 n。你可以假设 nums1 有足够的空间(空间大小大于或等于 m + n)来保存 nums2 中的元素。示例...
[LeetCode179]Largest Number
题目:Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed...
【leetcode❤python】 8. String to Integer (atoi)
#-*- coding: UTF-8 -*-#需要考虑多种情况#以下几种是可以返回的数值#1、以0开头的字符串,如01201215#2、以正负号开头的字符串,如‘+121215’;‘-1215489’#3、1和2和空格混合形式【顺序只能是正负号-0,空格位置可以随意】的:‘+00121515’#4、...
[LeetCode]Burst Balloons 爆气球
声明:原题目转载自LeetCode,解答部分为原创 Problem: Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by arr...
leetcode -- Burst Balloons -- 重点dp
https://leetcode.com/problems/burst-balloons/ 类似于矩阵连乘的问题,但与house robber问题不一样。这里是2D dp,决策变量是在那个位置burst,类似于划分问题。 这里dp是 bottom to up 思想。 参考:http://b...
[LeetCode] Employee Importance 员工重要度
You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id....
LeetCode25 Reverse Nodes in k-Group
题意:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then...
Leetcode 114
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x...
[leetcode]335. Self Crossing
You are given an array x of n positive numbers. You start at point (,) and moves x[] metres to the north, then x[] metres to the west, x[] metres to t...
【leetcode刷题笔记】Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest...
[leetcode-566-Reshape the Matrix]
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data....
[LeetCode] Merge Intervals 排序sort
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].Show TagsArr...
【LeetCode】56. Merge Intervals 解题报告(Python & C++ & Java)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/目录题目描述题目大意解题方法日期题目地址:https://leetcode.com/problems/merge-intervals/#/description题目描述Given a col...