原创 leetcode-07-reverse integer-python
Reverse digits of an integer. 反轉一個數,注意符號,溢出範圍。題目說的是32位int。 自己的思路:轉換成list,先拿出符號,然後不斷pop掉的字符加在一起最後如果沒溢出就輸出。感覺很妙,像堆棧
原创 leetcode-09-Palindrome Number
class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool
原创 leetcode-19-Remove Nth Node From End of List
題意:刪除鏈表從後往前開始的第n個節點。 單鏈表的操作。別人說用python來實現單鏈表沒有意義,好吧我不知道怎麼反駁暫且附和好了。python用list可以實現堆棧和隊列(pop(0)啥的…)。熟悉了鏈表的操作之後,本題的意思就
原创 leetcode-15-3sum
題目大意:給一個數組,選出其中所有的3個數加起來等於0的組合。 python: class Solution(object): def threeSum(self, nums): """
原创 leetcode-21-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-17-Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit t
原创 leetcode-16-3sum closest
題目:給一個list,一個target。找list中3個數相加最接近target的值。 class Solution(object): def threeSumClosest(self, nums, target):
原创 C++ 單鏈表基本操作分析與實現
鏈表 鏈表是一種物理存儲單元上非連續、非順序的存儲結構,數據元素的邏輯順序是通過鏈表中的指針鏈接次序實現的。鏈表由一系列結點(鏈表中每一個元素稱爲結點)組成,結點可以在運行時動態生成。每個結點包括兩個部分:一個是存儲數據元素的
原创 樹莓派遠程連接的三種方式總結
總結遠程連接樹莓派的三種方式,對大部分linux系統同樣適用。 首先需要將樹莓派連接上網,ifconfig記錄ip地址。 第一種:ssh遠程連接 在linux下使用 ssh [email protected] 可以登錄。
原创 leetcode-14-Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 題意:求最長前綴字符串。 python: class
原创 leetcode-18-4sum
class Solution { public: vector<vector<int> > fourSum(vector<int> &num, int target) { vector<vector<int
原创 堆VS棧
一、預備知識—程序的內存分配 一個由C/C++編譯的程序佔用的內存分爲以下幾個部分 1、棧區(stack)— 由編譯器自動分配釋放 ,存放函數的參數值,局部變量的值等。其 操作方式類似於數據結構中的棧。
原创 leetcode-13-roman to integer
羅馬數字轉換爲阿拉伯數字,同樣是0-3999之內。 class Solution(object): def romanToInt(self, s): """ :type s: str
原创 leetcode-10-Regular Expression Matching
正則匹配。最懶的方法,python直接re.match()。。 class Solution: # @return a boolean def isMatch(self, s, p):
原创 leetcode-08-String to Integer (atoi)
cpp: class Solution { public: int myAtoi(string str) { if(str.length() == 0) {