原创 LeetCode 24:兩兩交換鏈表中的節點(Swap Nodes in Pairs)解法彙總

文章目錄My Solution 更多LeetCode題解 My Solution 由於嘗試交換未成功,所以使用了一種討巧的方法:新建一個List,向這個List內添加結點。 struct ListNode { int val;

原创 LeetCode 26:刪除排序數組中的重複項(Remove Duplicates from Sorted Array)解法彙總

文章目錄My Solution 更多LeetCode題解 Given a sorted array nums, remove the duplicates in-place such that each element appea

原创 LeetCode 22:括號生成(Generate Parentheses)解法彙總

更多LeetCode題解 回溯法 class Solution { public: char paren[2] = { '(',')' }; vector<string> generateParenthesis(int n)

原创 LeetCode題解及源碼彙總

有些鏈接可能沒更新,都收錄在 Github # Title C++ Java Python Difficulty CSDN 1 Two Sum C++ Java Python Easy CSDN 2 Add Tw

原创 ReentrantLock基本使用

文章目錄lock()方法實現懶漢式單例condition實現進程通信使用lockInterruptibly()方法tryLock()應用忽略重複觸發帶參數tryLock:超時放棄參考 今天學習了java的lock和sychroni

原创 Java深拷貝詳細總結

文章目錄淺拷貝深拷貝無法重寫clone()時遍歷複製使用構造方法傳參複製使用list.addAll複製遍歷new序列化深拷貝參考 淺拷貝 直接看例子 package domain; public class Subject {

原创 算法競賽入門經典經典例題及習題題解

Github倉庫 有些例題沒找到完全相同的題目,找了類似的。 文章目錄算法競賽入門經典第一版第5章 基礎題目選解5.1 字符串5.2 高精度計算5.3 排序與檢索5.4 數學基礎第六章 數據結構基礎6.1 棧和隊列6.2 鏈表6.

原创 劍指offer刷題

劍指offer第二版 Example Problem Solution 2.3.1 數組(面試題3) 數組中重複的數字 JAVA 2.3.1 數組(面試題4) 二維數組中的查找 JAVA 2.3.2 字符串(

原创 LeetCode 1154:一年中的第幾天(Day of the Year)解法彙總

文章目錄Solution 更多LeetCode題解 Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, retur

原创 LeetCode 1169:查詢無效交易(Invalid Transactions)解法彙總

文章目錄Solution 更多LeetCode題解 A transaction is possibly invalid if: the amount exceeds $1000, or; if it occurs within

原创 LeetCode 1170:比較字符串最小字母出現頻次(Compare Strings by Frequency of the Smallest Character)解法彙總

文章目錄Solution 更多LeetCode題解 Let’s define a function f(s) over a non-empty string s, which calculates the frequency of

原创 LeetCode 48:旋轉圖像(Rotate Image)解法彙總

文章目錄Solution 更多LeetCode題解 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (c

原创 LeetCode 47:全排列 II(Permutations II)解法彙總

文章目錄Solution 更多LeetCode題解 Given a collection of numbers that might contain duplicates, return all possible unique p

原创 LeetCode 1144:遞減元素使數組呈鋸齒狀(Decrease Elements To Make Array Zigzag)解法彙總

文章目錄Solution 更多LeetCode題解 Given an array nums of integers, a move consists of choosing any element and decreasing i

原创 LeetCode 46:全排列(Permutations)解法彙總

文章目錄Solution 更多LeetCode題解 Given a collection of distinct integers, return all possible permutations. Example: Inpu