原创 [c++]計時方法——std::chrono
計時的作用:測試某一段代碼的運行時間,時間越短,則性能相對越高。 C++11 標準的”最佳計時方法“的代碼: #include <chrono> using namespace std; using namespace chron
原创 [C++] Clion中 Debug 和 Release編譯模式切換
(我的Clion是Ubuntu系統下的,可能會有些不同但是思路相同。) 1. 生成Release版本 點擊File->Settings->Build,Execution,Deployment->CMake,然後點擊+號,增加一個模式,
原创 c++單例模式及線程安全(懶漢模式 餓漢模式)
一、基礎的單例模式實現 構造函數聲明爲 private 或 protect ,防止被外部函數實例化; 內部保存一個 private static 的類指針保存唯一的實例; 實例的動作由一個 public 的類方法如 getInstance
原创 【解決方案】clion中the file does not belong to any project 問題
在用clion進行c++和cuda混合編程時,真的是踩了不少坑,這個提示碰到了好多次了。 原因可能是沒有關聯該文件所在的文件夾! 右鍵點擊它所在的文件夾,選擇Mark Directotry as,然後選擇Project Sources a
原创 [Leetcode]Generate Parentheses(生成括號)
一、題目描述 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For exam
原创 [LeetCode]Merge Two Sorted Lists(合併兩個有序鏈表)
一、題目描述: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the
原创 [leetcode]gas-station加油站(貪心)
問題描述: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car w
原创 騰訊2017暑期實習生編程題
題目一: 給定一個字符串s,你可以從中刪除一些字符,使得剩下的串是一個迴文串。如何刪除才能使得迴文串最長呢? 輸出需要刪除的字符個數。 輸出需要刪除的字符個數。 輸入描述: 輸入數據有多組,每組包含一個字符串s,且保證:1<=s.leng
原创 [LeetCode]candy分糖果
題目描述 There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these ch
原创 [LeetCode]linked-list-cycle ii 環形鏈表
問題描述 Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you
原创 [leetcode]reorder-list
題目描述: Given a singly linked list L: L 0→L 1→…→L n-1→L n, reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→… You must do this
原创 [leetcode]binary-tree-preorder-Traversal
題目描述: Given a binary tree, return the preorder traversal of its nodes' values. Note: Recursive solution is trivial, cou
原创 [leetcode]binary-tree-postorder-Traversal
題目描述: Given a binary tree, return the postorder traversal of its nodes' values. Note: Recursive solution is trivial, co
原创 maven入門——環境搭建
maven簡介: Maven是一個項目管理工具,基於項目對象模型(POM),可以通過一小段描述信息來管理項目的構建、報告和文檔的軟件項目管理工具。是一套強大的自動化構建工具。 它包含了一個項目對象模型 (Project Object Mo
原创 歸併排序實現c++版
|基本思路 歸併排序利用了遞歸的思想(而是分而治之的思想),將數組一分爲二,先將左半部分(座標爲0~mid)排好序,再將右半部分排好序(都是調用函數),最後將兩部分合並起來。整體算法時間複雜度爲O(nlogn),空間複雜度爲O(n)。 |