Problem Given a n,m which means the row and column of the 2D matrix and an array of pair A( size k). Originall…
标签:LeetCode
12. 整数转罗马数字
一、题目原型: 可参考 13. 罗马数字转整数 二、题目意思剖析: 其实就是和 13. 罗马数字转整数反着来 输入: 3 输出: "III" 输入: 4 输出: "IV" 输入: 9 输出: "IX" 输入: 58 输出…
283. 移动零
一、题目原型: 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 二、题目意思剖析: 示例: 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须…
Swift 二叉树的层次遍历 - LeetCode
LeetCode 题目: 二叉树的层次遍历 给定一个二叉树,返回其按层次遍历的节点值。 (即逐层地,从左到右访问所有节点)。 例如: 给定二叉树:[3,9,20,null,null,15,7], 3 / \ 9 20 /…
72. 最少编辑距离
题目描述 edit-distance 分析 Q1 我如何知道从一个单词 变成另外一个单词 需要做那个操作合适?插入|删除|替换 无限大问题 无法入手 每次操作一次字符 算一次编辑距离 操作次数o(n) 这是不是最优解 视…
python 两数之和
两数之和 python实现 解法1 不用说耗时长,复杂度 class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type t…
Swift 有效的数独 - LeetCode
题目:两数之和 描述: 判断一个数独是否有效,根据:Sudoku Puzzles – The Rules。 (数独规则: 每一行不能有重复的数字;每一列不能有重复的数字;将数独框划分为三行三列,没9个小方格不…
285. Inorder Successor in BST
Problem Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note…
[LintCode][System Design] Parking Lot
Problem More LeetCode Discussions Design a parking lot. see CC150 OO Design for details. n levels, each level …
277. Find the Celebrity
Problem Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one…
LeetCode 170. Two Sum III - Data structure design
题目 这个数据结构主要是把数据存储到unordered_multiset里,multiset类似set,但是它允许重复元素的存在。 这是cplusplus.com里关于unordered_multiset的指引 unor…
[LeetCode][DP] 265. Paint House II
Problem There are a row of n houses, each house can be painted with one of the k colors. The cost of painting …