- 博客(17)
- 收藏
- 关注
原创 LeetCode130. Surrounded Regions
题目: https://leetcode.com/problems/surrounded-regions/Given a 2D board containing ‘X’ and ‘O’, capture all regions surrounded by ‘X’.A region is captured by flipping all ‘O’s into ‘X’s in that surrou
2016-03-31 18:02:25 473
原创 LeetCode109. Convert Sorted List to Binary Search Tree
题目: https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:题意:给一个排好序的
2016-03-30 19:47:24 390
原创 LeetCode210. Course Schedule II
题目: https://leetcode.com/problems/course-schedule-ii/There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you ha
2016-03-29 21:00:22 511
原创 LeetCode89. Gray Code
题目: https://leetcode.com/problems/gray-code/The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number o
2016-03-28 17:13:26 417
原创 C/C++知识点整理(3)
1. C++中构造函数和析构函数可以抛出异常吗? A.都不行B.都可以C.只有构造函数可以D.只有析构函数可以答案:C构造函数尽量不抛异常,析构函数不要抛异常。 对于构造函数: 在构造函数中抛出异常,将导致正在构造的对象的析构函数不会被执行。当对象发生部分构造时,已经构造完成的子对象将被逆序的析构(即异常发生点前面的对象),而还没有开始构造的子对象将不会被构造了(即异常发生点后面的对象),但正在
2016-03-27 22:38:12 890 1
原创 LeetCode207. Course Schedule
题目: https://leetcode.com/problems/course-schedule/There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have
2016-03-27 20:50:55 393
原创 LeetCode337. House Robber III
题目: https://leetcode.com/problems/house-robber-iii/The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each
2016-03-23 20:34:40 1735
原创 C/C++知识点整理(2)
1.Which of following C++ code is correct?A. int f() { int *a = new int(3); return *a; }B. int *f() { int a[3] = {1, 2, 3}; return a; }C. vector<int> f() {vector<int> v(3); return v; }D. void f(int *
2016-03-22 21:54:03 518
原创 LeetCode133. Clone Graph
题目: https://leetcode.com/problems/clone-graph/Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ’s undirected graph serialization: Nodes are labeled u
2016-03-22 20:04:25 385
原创 LeetCode160. Intersection of Two Linked Lists
题目:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘
2016-03-17 15:39:16 353
原创 图论面试题
题目:给你一个描述关系的关系集: i vector<i>表示vector<i>中所有元素依赖于i….有n个依赖关系集。输入一个m,求所有m的最底层依赖。思路:有向图反转边向dfs。 其实就是把邻接表转化成逆邻接表再dfs往下找最底层依赖。 关键是转化成逆邻接表。 dfs往下递归到一条路径的最后一个,再回溯改变边的方向。cur为当前开始点,next=graph[cur][i] 即有cur->ne
2016-03-15 19:39:26 1592 2
原创 LeetCode332. Reconstruct Itinerary
题目: https://leetcode.com/problems/reconstruct-itinerary/Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of
2016-03-14 18:35:10 736
原创 Cocos2d-x中的缓存
cocos2d-x中有三个缓存类,在v2.x都是全局单例模式。纹理缓存(TextureCache)。使用纹理缓存可以创建纹理对象。精灵帧缓存(SpriteFrameCache)。能够从纹理图集(精灵表)中创建精灵帧缓存,然后再从精灵帧缓存中获得精灵对象,反复使用精灵对象时候,使用精灵帧缓存可以节省内存消耗。(如果将把图读入到精灵帧缓存中,同时也会把它加入到了纹理缓存里)动画缓存(Animati
2016-03-05 15:57:35 767
原创 Cocos2d-x中的精灵
Sprite精灵类创建Sprite精灵对象 创建精灵对象有多种方式,其中常用的函数如下:static Sprite* create()。创建一个精灵对象,纹理等属性需要在创建后设置。static Sprite* create(const std::string &filename)。指定图片创建精灵。static Sprite* create(const std::string &filen
2016-03-05 13:20:34 567
原创 Cocos2d-x中的字符串
使用const char*和std::stringconst char*是C风格的字符串,std::string是C++风格的字符串,它封装了const char*。 初始化std::string对象: std::string name=”tony”; std::string name=std::string(“tony”);std::string指针对象类型: std::string* n
2016-03-05 10:49:15 654
原创 蓝桥杯 地宫取宝
题目:问题描述 X 国王有一个地宫宝库。是 n x m 个格子的矩阵。每个格子放一件宝贝。每个宝贝贴着价值标签。 地宫的入口在左上角,出口在右下角。 小明被带到地宫的入口,国王要求他只能向右或向下行走。 走过某个格子时,如果那个格子中的宝贝价值比小明手中任意宝贝价值都大,小明就可以拿起它(当然,也可以不拿)。 当小明走到出口时,如果他手中的宝贝恰好是k件,则这些宝贝就可以送给小明。
2016-03-04 22:33:31 1214
原创 Cocos2d-x的坐标系
UI坐标与OpenGL坐标UI坐标 OpenGL坐标 OpenGL坐标转化UI坐标就是屏幕的高度减去OpenGL的y轴方向坐标,就是UI坐标下的y轴方向坐标,与之对应UI坐标转OpenGL坐标是高度减UI坐标。从UI坐标到OpenGL坐标的转换:Vec2 touchLocation=touch->getLocationView(); Vec2 touchLocation=Director::g
2016-03-01 22:43:48 587
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人