原创 COCOS CREATOR 按鈕註冊事件

點擊按鈕彈窗 註冊ontouchstart 回調,會有bug,界面還沒完全彈出,如果點擊時間很短,界面還沒彈出就沒了,必須一直按住,防止出發ontouchend, 註冊在ontouchend就沒事。 估計是ontouchend除法的時候會

原创 我才發現cocos js 和 cocos creator 內部是兩個引擎

裏面分別是網頁專用的H5引擎 和 native平臺的 2dx通過JSB綁定的引擎,雖然都是JS開發,但是不同平臺用的引擎是分開的,網頁是一套引擎。 這樣就會出現平時開發的時候,網頁版和手機版出現的問題不同。  以前我都不知道,最近開發CO

原创 排序鏈表

最垃圾的方法 冒泡排序 class Solution { public: ListNode* sortList(ListNode* head) { if(head == NULL) {

原创 哈希表居然比數組慢了這麼多LEETCODE 383 贖金信

class Solution { public: bool canConstruct(string ransomNote, string magazine) { int hehe[26] = {

原创 leetcode 1021 刪除最外層的括號

class Solution { public: stack<int>_stack; vector<int> pos; string strs; string removeOuterParentheses

原创 LEETCODE 全排列1

class Solution { public: vector<vector<int>>res; vector<int>clist; unordered_set<int> _set; vector<vec

原创 Codility PassingCars

int solution(vector<int> &A) { // write your code in C++14 (g++ 6.2.0) int res = 0; int total1 = 0; in

原创 LEETCODE 全排列 II

class Solution { public: unordered_set<int> _set; vector<vector<int>> reslist; void helper(int pos,vector<

原创 Codility練習 MaxCounters

vector<int> solution(int N, vector<int> &A) { // write your code in C++14 (g++ 6.2.0) int max = 0; int las

原创 dijkstra算法

#include <stdio.h> /* 算法描述 建立一個dis數組,長度是城市的數量n,每一個位置保存相應的city到達city1的最短距離 先找到距離city1最近的城市city x,然後遍歷它的相鄰城市,如果經過city x到

原创 LeetCode 821. 字符的最短距離

給定一個字符串 S 和一個字符 C。返回一個代表字符串 S 中每個字符到字符串 S 中的字符 C 的最短距離的數組。 示例 1: 輸入: S = "loveleetcode", C = 'e' 輸出: [3, 2, 1, 0, 1, 0

原创 算法複習1 堆

insert() 函數有以下三種用法:  1、在指定位置loc前插入值爲val的元素,返回指向這個元素的迭代器 2、在指定位置loc前插入num個值爲val的元素  3、在指定位置loc前插入區間[start, end)的所有元素  1、

原创 C學習筆記 13 atexit 在main函數調用結束後調用函數

atexit   函數名: atexit  功 能: 註冊終止函數(即main執行結束後調用的函數)  用 法: int atexit(atexit_t func);  注意:atexit()註冊的函數類型應爲不接受任何參數的void函

原创 C學習筆記 11 指針的減法

假設:  char*  p1 = ( char* )100;  short* p2 = ( short* )p1++;  int*   p3 = ( int* )p2++;  p3++;   請問:  p1 = ____________ 

原创 C學習筆記 9 共用體內存分配

// 共用體內存分配.cpp : 定義控制檯應用程序的入口點。// #include "stdafx.h" union A{    int a;    short b;    char c;    long long d;}; int _