原创 LeetCode(145)-二叉樹後序遍歷(遞歸、非遞歸)

import java.util.ArrayList; import java.util.Stack; public class l145_tree_postorder { class TreeNode{

原创 LeetCode(5)-Longest Palindromic Substring 最長迴文串兩種解法(中心擴散法、DP)

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000,

原创 Leetcode(136/137)Single Number-

Single Number1: Given an array of integers, every element appears twice except for one. Find that single one. Not

原创 LeetCode(118)-pascal triangle(楊輝三角)

Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5, Return [ [1]

原创 LeetCode(90)-Subsets II 子集合之二

Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a s

原创 LeetCode(101)-minimum-depth-binary-tree二叉樹最小深度

給定一棵二叉樹,找到它的最小深度。 最小深度問題就是就最短路徑的節點個數 /* 思路: 遞歸,若爲空樹返回0; 若左子樹爲空,則返回右子樹的最小深度+1;(加1是因爲要加上根這一層,下同) 若右子樹爲空,則返回左子樹的最小深度

原创 一道從室友那兒偷來的51信用卡筆試題-判斷字符串A是否包含字符串B

目前思路是分別掃描兩個字符串得到兩個map boolean judge(String str1,String str2){ HashMap<Character,Integer> map1=new Has

原创 LeetCode(106)Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates

原创 前端學習(day1)-前端基本概念的認知

http://2014.artsy.net/ https://codepen.io/Yakudoo/full/rJjOJx https://codepen.io/pissang/full/geajpX https://cod

原创 LeetCode(148)-sortlist 鏈表排序

Sort a linked list in O(n log n) time using constant space complexity. 解題思路: 1)將待排序數組(鏈表)取中點並一分爲二; 2)遞歸地對左半部分進行歸

原创 LeetCode(142)-linked-list-cycle求單鏈表中的環的起始點

Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follow up: Can you

原创 LeetCode(150)-Evaluate Reverse Polish Notation 計算逆波蘭表達式

Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each ope

原创 LeetCode(77)-Combinations 組合項

Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example, If n = 4 and

原创 LeetCode(138) Copy List with Random Pointer 拷貝帶有隨機指針的鏈表

A linked list is given such that each node contains an additional random pointer which could point to any node in t

原创 LeetCode(149)-Max Points on a Line 共線點個數

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 求最大的共線點的個數 pub