
leetcode题目
文章平均质量分 55
Doooer
这个作者很懒,什么都没留下…
展开
-
[LeetCode] 132 Pattern
题目描述: Given a sequence of n integers a1a1a_1, a2a2a_2, …, anana_n, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and aiaia_i < akaka_k < ajaja_j. Design an algorithm that ...原创 2018-05-12 09:25:20 · 218 阅读 · 0 评论 -
翻转字符串系列
leetcode 541. Reverse String II关键在于理清各种情况class Solution {public: string reverseStr(string s, int k) { int n = s.length(); int cnt=0; for(int i=0;i<n;i++){ ...原创 2019-01-13 15:37:09 · 203 阅读 · 0 评论 -
二叉树路径题目
leetcode 112 路径总和Ileetcode 113 路径总和IIleetcode 437 路径总和 IIIleetcode 257原创 2019-01-12 17:11:09 · 269 阅读 · 0 评论 -
回文的系列题目
一、判断一个字符串是不是回文串题目链接https://www.nowcoder.com/practice/df00c27320b24278b9c25f6bb1e2f3b8?tpId=69&amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;tqId=29674&amp;amp;amp;amp;amp;amp;rp=1&amp;amp;amp;amp;amp;amp;ru=/activity/oj&原创 2019-01-04 17:32:44 · 544 阅读 · 0 评论 -
有趣的数字
题目链接https://www.nowcoder.com/questionTerminal/af709ab9ca57430886632022e543d4c6考虑不到的点是 当出现重复数字的时候,差值最大和最下的对数计算问题。#include &amp;lt;iostream&amp;gt;#include &amp;lt;algorithm&amp;gt;using namespace std;int main(){...原创 2019-01-04 11:41:54 · 1012 阅读 · 0 评论 -
字符移位
https://www.nowcoder.com/question/next?pid=1725829&qid=44802&tid=20692948题目:小Q最近遇到了一个难题:把一个字符串的大写字母放到字符串的后面,各个字符的相对位置不变,且不能申请额外的空间。冒泡思想#include <iostream>using namespace std;int ma...原创 2019-01-04 09:34:04 · 222 阅读 · 0 评论 -
最长公共子序列
不同于子串,子序列是不连续的。这时无法暴力穷举。https://www.nowcoder.com/questionTerminal/c996bbb77dd447d681ec6907ccfb488a动态规划法:class LCS {public: int findLCS(string A, int n, string B, int m) { vector&amp;lt;vec...原创 2019-01-03 20:42:09 · 275 阅读 · 0 评论 -
最长公共子串
最长公共子串https://www.nowcoder.com/questionTerminal/02e7cc263f8a49e8b1e1dc9c116f7602暴力法:class LongestSubstring {public: int findLongest(string A, int n, string B, int m) { int res = 0; ...原创 2019-01-03 19:22:42 · 266 阅读 · 0 评论 -
二叉树的遍历:前序、中序、后序和层次遍历
层次遍历/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */...原创 2018-11-27 11:39:33 · 286 阅读 · 0 评论 -
剑指offer(41-68题)
P214数据流中的中位数原创 2018-11-25 14:32:15 · 358 阅读 · 0 评论 -
剑指offer(21-40题)
P129调整数组顺序使奇数位于偶数前面void reOrderArray(vector&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;int&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt; &amp;amp;amp;amp;amp;amp;amp;am原创 2018-11-04 22:06:04 · 667 阅读 · 1 评论 -
剑指offer(1-20题)
考虑是否全面:P29将一个字符串转换为整数非数字字符 2. 正负号 3.最大正整数,最小负整数以及溢出空指针P30求链表中的倒数第K个节点空指针 2. 节点总数小于KP55二维数组中的查找:每一行递增,每一列递增解法:从右上角开始或者左下角...原创 2018-10-27 15:57:21 · 279 阅读 · 0 评论 -
2sum、3sum、4sum
这类问题,要先将数组进行排序,然后用夹逼法则(首尾指针)。最终都可以化解为2sum的问题,但是要注意过程中的去重步骤。leetcode链接:https://leetcode.com/problems/two-sum/description/https://leetcode.com/problems/3sum/description/https://leetcode.com/problems...原创 2018-10-12 14:45:14 · 252 阅读 · 0 评论 -
编程题---位运算考察(游戏任务标记)
牛客网上的一道编程题:https://www.nowcoder.com/practice/2f45f0ef94724e06a4173c91ef60781c?tpId=85&amp;tqId=29871&amp;tPage=1&amp;rp=1&amp;ru=/ta/2017test&amp;qru=/ta/2017test/question-ranking题目描述: 游戏里面有很多各式...原创 2018-07-09 11:02:02 · 700 阅读 · 0 评论 -
Trapping Rain Water(leetcode hard)
这是自己在面试微软过程中遇到的编程题,印象比较深刻是因为当时自己尝试想了很多方法都是不对的。果然,这就是hard题目的魅力。思想:考虑在每一个位置,它可以存多少水。这取决于它左边最高的板子,它右边最高的板子,这两者的最小值高于当前位置多少。下面的代码里,forward和backward分别记录的是包括当前位置的板子的最高值。仔细想了下,是否包括当前位置,都是OK的。class Solutio...原创 2019-04-30 20:55:27 · 209 阅读 · 0 评论