原创 pat水題
自以爲對二進制有很深的理解,面對這種水題,切了好久。。。 題目鏈接 #include <stdio.h> #include <climits> typedef long long ll; bool compare(ll a, ll b
原创 pat水題
題目鏈接 int main() {char a[100], b[100];int a1, b1, c1, a2, b2, c2,a3,b3,c3;scanf("%d.%d.%d", &a1, &b1, &c1);scanf("%d.%d.
原创 pat stack模擬,老超時wa......
#include <stack> #include <iostream> #include <vector> #include <algorithm
原创 LeetCode算法搜索
Given a 2D board containing'X'and'O', capture all regions surrounded by'X'. A region is captured by flipping all'O's
原创 快排的遞歸和非遞歸版
#include<iostream>#include<vector>#include<stack>#include<cstdlib>#include<algorithm>using namespace std; /**把數組分爲兩部分,軸
原创 pat 中求解最長迴文串的長度
本以爲暴力枚舉會超時,但竟然過了。。。 #include <string> #include <stdio.h> #include <iostream> int longestPalindrome(string s) {int left
原创 PAT題目 有幾個PAT(25)
題目鏈接 有點動態規劃的味道。 #include <stdio.h> int main() {char s[100];int p=0, pa=0, pat=0;scanf("%s", s);int len = strlen(s);for
原创 LeetCode word latter
題目描述 Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from s
原创 Word_ladder
題目鏈接 參考了大神的代碼 #include <unordered_map> #include <unordered_set> class Solution { public:void gen_path(unordered_map<str
原创 scramble string (使用動態規劃和遞歸做)
點擊打開鏈接 class Solution { public:bool solve(string s1, string s2, int left1, int right1, int left2)//串的位置{int dist = righ
原创 LeetCode二叉樹的層序遍歷的輸出
題目鏈接 struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x),
原创 LeetCode 重建BST
點擊打開鏈接 struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x
原创 LeetCode decode ways
點擊打開鏈接 class Solution { public: bool isdigit(char c){return c >= '0'&&c <= '9';}int numDecodings(string s) {int dp[
原创 leetcode 字符串枚舉
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindr
原创 劍指offer 旋轉數組的最小數字
題目: 把一個數組最開始的若干個元素搬到數組的末尾,我們稱之爲數組的旋轉。 輸入一個非遞減排序的數組的一個旋轉,輸出旋轉數組的最小元素。 例如數組{3,4,5,1,2}爲{1,2,3,4,5}的一個旋轉,該數組的最小值爲1。 NOTE