• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






乘风有时

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

随笔分类 -  C++

上一页 1 2 3 4 下一页

 
[LeetCode]Increasing Triplet Subsequence
摘要:题目:Increasing Triplet Subsequence Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally th 阅读全文
posted @ 2017-06-19 11:03 乘风有时 阅读(143) 评论(0) 推荐(0)
[LeetCode]Patching Array
摘要:题目:Patching Array Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n]inc 阅读全文
posted @ 2017-06-17 21:54 乘风有时 阅读(168) 评论(0) 推荐(0)
[LeetCode]Longest Increasing Path in a Matrix
摘要:题目:Longest Increasing Path in a Matrix Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to 阅读全文
posted @ 2017-06-17 21:38 乘风有时 阅读(149) 评论(0) 推荐(0)
[LeetCode]Odd Even Linked List
摘要:题目:Odd Even Linked List Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the 阅读全文
posted @ 2017-06-08 22:30 乘风有时 阅读(270) 评论(0) 推荐(0)
[LeetCode]Count of Range Sum
摘要:题目:Count of Range Sum Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined a 阅读全文
posted @ 2017-06-07 22:19 乘风有时 阅读(318) 评论(0) 推荐(0)
[LeetCode]Reverse Bits
摘要:题目:Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Have you thought about this? Here are so 阅读全文
posted @ 2017-05-18 22:52 乘风有时 阅读(316) 评论(0) 推荐(0)
C++基础之关联容器
摘要:关联容器 关联容器和顺序容器的本质区别:关联容器是通过键存取和读取元素、顺序容器通过元素在容器中的位置顺序存储和访问元素。因此,关联容器不提供front、push_front、pop_front、back、push_back以及pop_back,此外对于关联容器不能通过容器大小来定义,因为这样的话将 阅读全文
posted @ 2017-05-18 11:00 乘风有时 阅读(234) 评论(0) 推荐(0)
[LeetCode]Wiggle Sort
摘要:题目:Wiggle Sort II Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example:(1) Given nums = [1, 5, 1, 1, 6 阅读全文
posted @ 2017-05-17 21:44 乘风有时 阅读(235) 评论(0) 推荐(0)
C++基础之string类
摘要:string也是属于顺序容器,但是string类很重要且经常使用,因此在这里单独记录。 string的操作总结 string(const char *s,int n); //用c字符串s初始化,s应至少含有n个字符string(s2,pos2); //s2从下标pos2开始的字符的拷贝,pos2>s 阅读全文
posted @ 2017-05-17 09:41 乘风有时 阅读(292) 评论(0) 推荐(0)
C++基础之迭代器
摘要:迭代器的分类 插入迭代器(insert iterator):绑定一个容器上后可以向容器中插入元素; 流迭代器(stream iterator):绑定在输入输出流中,可以遍历关联的流; 反向迭代器(reverse iterator):迭代器向后移动,标准库容器中除了forward_list外都有反向迭 阅读全文
posted @ 2017-05-16 22:48 乘风有时 阅读(499) 评论(0) 推荐(0)
[LeetCode]Range Sum Query
摘要:题目:Range Sum Query - Immutable Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Note: 给定 阅读全文
posted @ 2017-05-11 22:48 乘风有时 阅读(285) 评论(0) 推荐(0)
[LeetCode]Perfect Squares
摘要:题目:Perfect Squares 给定一个正整数n,找到总和为n的最小数量的完美平方数(例如,1,4,9,16,...)。 For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return 2 bec 阅读全文
posted @ 2017-05-08 12:07 乘风有时 阅读(506) 评论(0) 推荐(0)
[LeetCode]Integer to English Words
摘要:题目:Integer to English Words Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For 阅读全文
posted @ 2017-05-07 19:42 乘风有时 阅读(160) 评论(0) 推荐(0)
[LeetCode]Missing Number
摘要:题目:Missing Number 给定一个从0,1,2,...,n中取出的n个不同数字的数组,找到数组中缺少的数字。 Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that 阅读全文
posted @ 2017-05-07 17:37 乘风有时 阅读(190) 评论(0) 推荐(0)
[LeetCode]Sliding Window Maximum
摘要:题目:Sliding Window Maximum 给定一个数组和滑动窗口的大小,窗口从开始位置每次向后滑动一格,找出每次窗口的最大值; 思路: 记录当前窗口的最大值下标,每次移动一格时,最小下标会移出窗口,邻接着的最大下标会移入窗口; 因此,每次窗口移动时,首先比较移入的是否比当前最大值还大,是则 阅读全文
posted @ 2017-05-06 23:22 乘风有时 阅读(135) 评论(0) 推荐(0)
[LeetCode]Basic Calculator
摘要:题目:Basic Calculator 给定一个合法的运算表达式,该表达式中只包含数字、'+'、'-'、' '、'('、')'。 思路: 简单思考不用看成加减两种运算,直接看成加法,只不过由正负; 如何处理括号呢?因为只看成加法,括号会影响的是数值的正负,那么通过去括号运算法则来修改当前值的正负就可 阅读全文
posted @ 2017-05-04 22:20 乘风有时 阅读(211) 评论(0) 推荐(0)
[LeetCode]Contains Duplicate
摘要:题目:Contains Duplicate 给定整数数组,查找数组是否包含任何重复项。 如果数组中的任何值至少出现两次,则函数应返回true,如果每个元素都不同,则返回false。 思路: 可以使用桶排序的思想来,遍历所有元素,通过元素值直接访问标志,当第一次遇到则设标志,第二次遇到就跳出循环。 但 阅读全文
posted @ 2017-05-03 17:58 乘风有时 阅读(246) 评论(0) 推荐(0)
C++基础之泛型算法
摘要:标准库并未给每个容器添加大量功能,因此,通过大量泛型算法,来弥补。这些算法大多数独立于任何特定的容器,且是通用的,可用于不同类型的容器和不同的元素。 迭代器使得算法不依赖容器,但是算法依赖于元素的类型操作;例如某些算法需要元素支持"<"运算。 算法永远不会执行容器操作,它们只会运行于迭代器之上,执行 阅读全文
posted @ 2017-05-02 22:55 乘风有时 阅读(250) 评论(0) 推荐(0)
[LeetCode]Shortest Palindrome
摘要:题目:Shortest Palindrome 给定字符串,在前面增加最少字符使其组成回文字符串。 思想: 只要找到从字符串头部开始的最长回文子串,就能将剩下的字符串逆置后拼接到前面而得到最短的回文字符串。 /**判断字符串是回文的**/ bool isPalindrome(string s){ if 阅读全文
posted @ 2017-05-02 17:43 乘风有时 阅读(157) 评论(0) 推荐(0)
[LeetCode]House Robber
摘要:题目:House Robber 给定一个数组求最大和,要求求和的每个元素不能相邻。 思路: 不要想太复杂,每次记录当前的最大值和前一个位置的最大值,然后比较即可。 具体就是动态规划的思想: F(i)表示数组前i项中符合上面要求的最大和;choose(i) = true表示F(i)的和中第i项被选中了 阅读全文
posted @ 2017-05-02 14:32 乘风有时 阅读(141) 评论(0) 推荐(0)
 

上一页 1 2 3 4 下一页