原创 LeetCode OJ 566. Reshape the Matrix

LeetCode OJ 566. Reshape the Matrix Description In MATLAB, there is a very useful function called ‘reshape’, which can

原创 算法概論8.8

算法概論8.8 問題描述 在精確的4SAT(EXACT 4SAT)問題中,輸入爲一組子句,每個子句都是恰好4個文字的析取,且每個變量最多在每個子句中出現一次。目標是求它的滿足賦值——如果該賦值存在。證明精確的4SAT是NP-完全問題。

原创 NowCoder 劍指Offer_編程題 鏈表中環的入口節點

NowCoder 鏈表中環的入口節點 Description 一個鏈表中包含環,請找出該鏈表的環的入口結點。 解題思路 兩個指針p,q從表頭出發遍歷鏈表,p每次走一步,q每次走兩步。如果鏈表中有環,那麼p,q最終會相遇。設p走了x步,q

原创 LeetCode OJ 155. Min Stack

LeetCode OJ 155. Min Stack Description Design a stack that supports push, pop, top, and retrieving the minimum element

原创 LeetCode OJ 226. Invert Binary Tree

LeetCode OJ 226. Invert Binary Tree Description Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6

原创 LeetCode OJ 13. Roman to Integer

LeetCode OJ 13. Roman to Integer Description Given a roman numeral, convert it to an integer. Input is guaranteed to b

原创 LeetCode OJ 496. Next Greater Element I

LeetCode OJ 496. Next Greater Element I Description You are given two arrays (without duplicates) nums1 and nums2 wher

原创 LeetCode OJ 56. Merge Intervals

LeetCode OJ 56. Merge Intervals Description Given a collection of intervals, merge all overlapping intervals. For exam

原创 LeetCode OJ 141. Linked List Cycle

LeetCode OJ 141. Linked List Cycle Description Given a linked list, determine if it has a cycle in it. Follow up: Can

原创 LeetCode OJ 239. Sliding Window Maximum

LeetCode OJ 239. Sliding Window Maximum Description Given an array nums, there is a sliding window of size k which is

原创 LeetCode OJ 160. Intersection of Two Linked Lists

LeetCode OJ 160. Intersection of Two Linked Lists Description Write a program to find the node at which the intersecti