自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 资源 (1)
  • 收藏
  • 关注

原创 leetcode---C++实现---524. Longest Word in Dictionary through Deleting(通过删除字母匹配到字典里最长单词)

题目level:mediumGiven a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lex

2020-05-24 22:19:30 237

原创 leetcode---C++实现---141. Linked List Cycle(环形链表)

题目level:easyGiven a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no c

2020-05-24 21:50:39 220

原创 leetcode---C++实现---88. Merge Sorted Array(合并两个有序数组)

题目level:easyGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that nums1 has enough space (size that is great

2020-05-24 21:30:59 247

原创 leetcode---C++实现---680. Valid Palindrome II(验证回文字符串 II)

题目level: easyGiven a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.Example 1:Input: “aba”Output: TrueExample 2:Input: “abca”Output: TrueExplanation: You could delete the character ‘c’.Not

2020-05-24 21:05:36 231

原创 leetcode---C++实现---345. Reverse Vowels of a String(反转字符串中的元音字母)

题目level: easyWrite a function that takes a string as input and reverse only the vowels of a string.Example 1:Input: “hello”Output: “holle”Example 2:Input: “leetcode”Output: “leotcede”Note:The vowels does not include the letter “y”.来源:力扣(Leet

2020-05-24 20:34:46 180

原创 leetcode---C++实现---633. Sum of Square Numbers(平方数之和)

题目level: easyGiven a non-negative integer c, your task is to decide whether there’re two integers a and b such that a2 + b2 = c.Example 1:Input: 5Output: TrueExplanation: 1 * 1 + 2 * 2 = 5Example 2:Input: 3Output: False来源:力扣(LeetCode)链接:https://

2020-05-24 16:56:51 645

原创 leetcode---C++实现---167. Two Sum II - Input array is sorted(两数之和 II - 输入有序数组)

题目level:easyGiven an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where

2020-05-24 16:29:04 126

原创 leetcode---C++实现---11. Container With Most Water(盛最多水的容器)

题目Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, s

2020-05-17 17:49:57 200

原创 leetcode---C++实现---26. Remove Duplicates from Sorted Array(删除排序数组中的重复项)

题目Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.Ex

2020-05-17 17:37:40 150

原创 leetcode---C++实现---98. Validate Binary Search Tree(验证二叉搜索树)

题目解题思路二叉搜索树的特性为:(节点为二叉搜索树上的任一节点)节点的左子树所有节点均比当前节点值小;节点的右子树所有节点均比当前节点值大。方法1:根据上述特性,可以采用递归方法实现,向下递归时,传递左右子树的取值范围;方法2:另一种递归方式是:判断节点的左子树是否为有效的二叉搜索树,再判断当前节点的数值是否比左儿子大,再判断节点的右子树是否为有效的二叉搜索树,判断右儿子的值是否比当前节点数值大;方法3:利用二叉树中序遍历结果为从小到大依次排列的特性。算法实现方法1:/**

2020-05-17 17:22:32 144

原创 leetcode---C++实现---104. Maximum Depth of Binary Tree(二叉树的最大深度)

题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children.Example:Given binary tree [3,9,20,null,null,15,7],

2020-05-17 17:00:57 110

原创 leetcode---C++实现---589. N-ary Tree Preorder Traversal(N叉树的前序遍历)

题目Given an n-ary tree, return the preorder traversal of its nodes’ values.Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples).Follow up:Recursive solution is

2020-05-17 16:54:17 151

原创 leetcode---C++实现---144. Binary Tree Preorder Traversal(二叉树的前序遍历)

题目Given a binary tree, return the preorder traversal of its nodes’ values.Example:Input: [1,null,2,3]1\2/3Output: [1,2,3]Follow up: Recursive solution is trivial, could you do it iteratively?来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/bi

2020-05-17 16:34:29 148

原创 leetcode---C++实现---面试题59 - I. 滑动窗口的最大值

题目给定一个数组 nums 和滑动窗口的大小 k,请找出所有滑动窗口里的最大值。示例:输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3输出: [3,3,5,5,6,7]解释:滑动窗口的位置最大值[1 3 -1] -3 5 3 6 731 [3 -1 -3] 5 3 6 731 3 [-1 -3 ...

2020-05-17 16:15:27 257

原创 leetcode---C++实现---1047. Remove All Adjacent Duplicates In String(删除字符串中所有相邻重复项)

题目Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them.We repeatedly make duplicate removals on S until we no longer can....

2020-05-06 00:33:24 203

原创 leetcode---C++实现---1021. Remove Outermost Parentheses(删除最外层的括号)

题目A valid parentheses string is either empty (""), “(” + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, “”, “()”, “(())()”, and “...

2020-05-05 23:36:37 187 1

原创 leetcode---C++实现---844. Backspace String Compare(比较含退格的字符串)

题目Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.Note that after backspacing an empty text, the text will continue emp...

2020-05-05 22:02:44 237

原创 leetcode---C++实现---682. Baseball Game(棒球比赛)

题目You’re now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round’s score): Directly represents the number of points you get i...

2020-05-05 17:09:11 428

原创 leetcode---C++实现---496. Next Greater Element I(下一个更大元素I)

题目You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2...

2020-05-05 12:57:08 208

原创 leetcode---C++实现---232. Implement Queue using Stacks(用栈实现队列)

题目Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue.pop() – Removes the element from in front of queue.peek() – Get the front element.empty...

2020-05-05 11:06:24 195

原创 leetcode---C++实现---225. Implement Stack using Queues(用队列实现栈)

题目Implement the following operations of a stack using queues.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get the top element.empty() – Return whet...

2020-05-04 23:11:13 114

原创 leetcode---C++实现---155. Min Stack(最小栈)

题目Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get...

2020-05-04 20:28:04 502

原创 leetcode---C++实现---20. Valid Parentheses(有效的括号)

题目Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of...

2020-05-03 21:31:30 113

原创 二叉搜索树基本操作原理与C++实现

二叉搜索树二叉搜索树为一种特殊的二叉树,除二叉树的性质外,其特有的性质为: 对于树中每个节点X,其左子树中所有项的值均小于X项中的值,且其右子树中所有项的值均大于X中的值。二叉搜索树除二叉树的遍历操作外,还需掌握的操作有:查找节点、插入节点和删除节点。查找节点包括查找一棵树的最大值、最小值、指定值。二叉树的四种遍历方式的介绍与实现想了解的小伙伴儿们可以参看我之前的博客二叉树遍历原理及C++实现...

2020-02-23 16:53:04 129

原创 二叉树遍历原理及C++实现

二叉树遍历二叉树遍历有四种形式:先序遍历、中序遍历、后序遍历和层序遍历,其中先序、中序、后序遍历均有递归遍历和非递归遍历两种方式。本文将介绍这四种遍历的原理与C++实现。不熟悉C++的小伙伴儿可以不关注程序具体实现,只查阅其实现思路即可。准备工作首先,我们先定义下树节点结构,并假设节点中存储的是int类型的数据,实现如下:class TreeNode{public: TreeNode...

2019-12-29 18:48:36 646 1

原创 各类树简要说明与对比

二叉树(binary tree)二叉树每个节点都不能有多于两个的儿子。二叉查找树(ADT)对于树中每个节点X,它的左子树中所有项的值均小于X中的项,而它右子树中所有项的值均大于X中的值。AVL树(带有平衡条件的二叉查找树)属于二叉查找树,且对于树中每个节点,其左子树和右子树的高度最多差1。伸展树保证从空树开始任意连续M次对树的操作最多花费O(MlogN)时间。其基本想法是,当一个节点...

2019-12-17 22:59:11 330

原创 插入排序详解及C++实现

插入排序插入排序是一种简单直接的排序算法,其实质是将一个元素插入有序序列中,并保证插入后的序列仍有序。算法步骤将第一个元素看做一个有序序列,剩余元素为无序序列;从无序序列中取出第一个元素,与有序序列从后往前顺序的元素比较;若有序序列中元素比待排序元素大,则将有序序列中的元素后移一位,直到有序元素中有元素不大于待排序元素或有序序列全部比较完毕;此时有序序列多了一个元素,而无序序列少了一个元...

2019-11-24 22:09:29 342

原创 选择排序详解及C++实现

选择排序选择排序是一种简单直接的排序算法,其实质是在未排序序列中找到最小(大)元素,将其放在已排序序列的末尾(开始)位置。算法步骤以每次找到最大元素的方法为例:从前到后,在未排序序列中查找最大元素,将该最大元素与序列末尾数据进行交换;再从剩余未排序元素中继续寻找最大元素,将该最大元素与已排序序列前一个元素进行交换,即将该元素放在已排序序列开始的位置;重复第2步,直到所有元素均排序完毕...

2019-11-24 16:45:27 545

原创 冒泡排序详解

冒泡排序冒泡排序算法名字的由来是因为越小的元素经由交换慢慢“浮”到数列的顶端(升序或降序排列),就如同碳酸饮料中二氧化碳的气泡最终会上浮到顶端一样,故名“冒泡排序”。其实质是把小(大)的元素往前(后)调。算法步骤以把大的元素往后调的比较方法为例:从前到后,依次比较相邻两元素。若第一个元素比第二个元素大,就交换他们的位置;比较交换了所有元素后,最大的数将是最后的元素,该元素不再参与新一轮...

2019-11-09 15:54:35 320

原创 C++ 模板

模板是C++中泛型编程的基础。一个模板就是一个创建类或函数的公式,使用模板能够让程序员编写与类型无关的代码。函数模板假定我们希望编写一个函数来比较两个值的大小,由于C++语言定义函数或变量时都必须确定其数据类型,因此对于不同的数据类型,比较函数都必须定义一份,以int、double和string为例:int compare(const int &v1, const int &...

2019-10-05 18:40:49 157

原创 protobuf初体验

protobuf安装1.开发环境操作系统:Red Hat Enterprise Linux Server release 7.1 (Maipo)使用语言:C++(本次使用C++语言)源码版本:https://github.com/protocolbuffers/protobuf/releases/latest protobuf-cpp-3.9.1.tar.gz官方安装说明:https...

2019-09-09 16:46:09 270

原创 C#调用Qt编写的带界面的dll

C#调用Qt编写的带界面的dllQt编写带界面的dllC#调用实现结果Qt编写带界面的dllQt编写的带界面的dll程序,由于Qt必须调用QApplication的exec方法才能运行,所以在普通windows程序中是不能调用的,Qt提供了解决方案qtwinmigrate。开发环境操作系统:win10Qt Create版本:qt-creator-opensource-windows-x...

2019-03-26 20:19:58 9479 4

Qt在线切换语言Demo

提供Qt实现在线动态切换语言的示例Demo,包括主窗口和子窗口控件的语言动态切换。

2019-04-15

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除