Implement the following operations of a stack using queues. push(x) — Push element x onto stack. …
分类:LeetCode
[LeetCode] Flip Game II 翻转游戏之二
You are playing the following Flip Game with your friend: Given a string that contains only these two c…
【leetcode】93. Restore IP Addresses 无分隔符字符串ip形式的可表示的所有合法ip集合
1. 题目 Given a string containing only digits, restore it by returning all possible valid IP address combination…
LeetCode--Merge Sorted Array
Difficulty: Easy 【题目】Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You ma…
[剑指offer] 二叉树中和为某一值的路径
题目描述 输入一颗二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。 解题思路 用前序遍历的方式访问到某一结点时,把该结点添加到路径上,并…
301. Remove Invalid Parentheses
Hard超高频 看了很久Discussion里面最高票的答案,一直没看懂。晚上开始看后面的答案,发现了一个BFS的方法比较好理解。其实这个方法的思路很brute force, 就是每次我们删掉一个括号(左或右),检查剩下…
[LeetCode By Go 29]492. Construct the Rectangle
马上写了30道题目了,使用golang写起题目来代码简洁明了,还可以非常方便的写测试用例,加上Goland可以进行调试,有如神助。 但无论如何,写了测试就会依赖测试判断对错,用了debug就会依赖debug来寻找出错的地…
Distinct Subsequences
Problem Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of…
[LeetCode] Word Pattern II 词语模式之二
Given a pattern and a string str, find if strfollows the same pattern. Here fo…
[LeetCode] Power of Four 判断4的次方数
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given…
[LeetCode] Bomb Enemy 炸弹人
Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return th…
[LeetCode] Kth Smallest Number in Multiplication Table 乘法表中的第K小的数字
Nearly every one have used the Multiplication Table. But could you find out the k-th sma…