leetcode-cn.com/problem 题意 简单问题,直接暴力即可。 思路 如果仅要求交换一次就可完成两个字符串的相等排列,我们即判断字符串是否只有两个字符不同,然后判断是否相等。 代码 class Solution { public: bool areAlmostEqual(string s1, string s2) { int n = s1.size()
https://leetcode-cn.com/problems/implement-queue-using-stacks/solution/yong-zhan-shi-xian-dui-lie-by-leetcode/
Problem 2: Leetcode 232 请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作(push、pop、peek、empty): 实现MyQueue 类: void push(int x) 将元素 x 推到队列的末尾 int pop() 从队列的开头移除并返回元素 int peek() 返回队列开头的元素 boolean empty() 如果队列为空,返回 true ;...
The problem solutions and implementations are entirely provided by Alex Prut. The code is not refactored, no coding style is followed, the only purpose of the written code is to pass all the platform tests of a given problem.Problems
642 Design Search Autocomplete System: it is a autocomplete system. which is also widely used. use trie to solve this problem is better. 716 max Stack: this can also using two stacks to solve this problem. if you take a look at the solution, you will find that is genius. I’m so ...
232.Implement-Queue-using-Stacks (H-) 341.Flatten-Nested-List-Iterator (M) 173.Binary-Search-Tree-Iterator (M) 536.Construct-Binary-Tree-from-String (M) 456.132-Pattern (H-) 636.Exclusive-Time-of-Functions (H-) 856.Score-of-Parentheses (M+) 946.Validate-Stack-Sequences(H-) 1190.Reve...
218 The Skyline Problem 16.20% Hard 217 Contains Duplicate 35.90% Easy 216 Combination Sum III 27.70% Medium 215 Kth Largest Element in an Array 27.30% Medium 214 Shortest Palindrome 16.80% Hard 213 House Robber II 26.30% Medium 212 Word Search II 15.00% Hard 211 Add and Search Word - Dat...
1 Two Sum Solution O(n) O(n) Easy HashMap 2 Add Two Numbers Solution O(max(m,n)) O(1) Medium LinkedList 3 Longest Substring Without Repeating Characters Solution O(n) O(k) Medium HashMap, Sliding Window 4 Median of Two Sorted Arrays Solution ? ? Hard Divide and Conquer 5 Longest...
LeetCode 刷题随手记 - 第一部分 前 256 题(非会员),仅算法题,的吐槽 https://leetcode.com/problemset/algorithms/...
218 The Skyline Problem Algorithms Hard 217 Contains Duplicate Algorithms Easy 216 Combination Sum III Algorithms Medium 215 Kth Largest Element in an Array Algorithms Medium 214 Shortest Palindrome Algorithms Hard 213 House Robber II Algorithms Medium 212 Word Search II Algorithms Hard 211 Add and Se...