234 Palindrome Linked List

/** * Definition for singly-linked list. * struct ListNode { *     int val; *     ListNode *next; *     ListNode(int x) : val(x), next(NULL) {} * }; ...

2018-05-17 10:57:38

阅读数:23

评论数:0

49. Group Anagrams

class Solution {public:    vector<vector<string>> groupAnagrams(vector<string>&...

2018-05-17 10:44:05

阅读数:22

评论数:0

240. Search a 2D Matrix II

class Solution {public: bool searchMatrix(vector<vector<int>>& matrix, int target) {    int m...

2018-05-17 10:25:25

阅读数:25

评论数:0

235. Lowest Common Ancestor of a Binary Search Tree

/** * Definition for a binary tree node. * struct TreeNode { *     int val; *     TreeNode *left; *     TreeNode *right; *     TreeNode(int x) : val(...

2018-05-17 10:21:11

阅读数:18

评论数:0

682. Baseball Game

class Solution {public:    int calPoints(vector<string>& ops) {        stack<int> s;        i...

2018-05-17 10:06:26

阅读数:20

评论数:0

387. First Unique Character in a String

class Solution {public: int firstUniqChar(string s) { int idx = s.size(); map<int, pair<int, int>> mp; ...

2018-05-17 10:02:17

阅读数:22

评论数:0

17 Letter Combinations of a Phone Number

/*String[] mapping = new String[] {"0", "1", "abc", "def", "ghi&...

2018-05-17 09:58:37

阅读数:23

评论数:0

238. Product of Array Except Self

class Solution {public:    vector<int> productExceptSelf(vector<int>& nums) {        int prod...

2018-05-17 09:54:44

阅读数:21

评论数:0

42. Trapping Rain Water

/*[4,2,3] is KO 0,should be 1class Solution {public: int trap(vector<int>& height) { if (height.size()<...

2018-05-17 09:30:03

阅读数:17

评论数:0

239. Sliding Window Maximum

/* Memory Limit Exceeded Jacob Given nums = [1,3,-1,-3,5,3,6,7], and k = 3. is OK*//*class Solution {public:    vector<int> max...

2018-05-17 09:28:11

阅读数:22

评论数:0

121. Best Time to Buy and Sell Stock

/*We need to find out the maximum difference (which will be the maximum profit) between two numbers in the given array. Also, the second number (sell...

2018-05-15 17:37:09

阅读数:29

评论数:0

5. Longest Palindromic Substring

class Solution {public:    string longestPalindrome(string s) {        if (s.size() == 1 || s.size() == 0) return s;        int min_start=0, max_len=...

2018-05-15 17:36:38

阅读数:21

评论数:0

236. Lowest Common Ancestor of a Binary Tree

/*Acception!*/class Solution {public:TreeNode * dfsTraverse(TreeNode * root, TreeNode * p , TreeNode * q){    if( root == p || root == q || root == N...

2018-05-15 16:55:27

阅读数:19

评论数:0

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 the list or null.Return a deep copy...

2018-05-15 16:53:23

阅读数:21

评论数:0

438. Find All Anagrams in a String

/*Acception of mine using template.1. //create a hashmap to save the Characters of the target substring.    //(K, V) = (Character, Frequence of the C...

2018-05-15 16:30:15

阅读数:21

评论数:0

48. Rotate Image

/*观察上面数据,需要做两步完成旋转1. a[i][j] = a[j][i]2. 然后对每行反序。  */class Solution {public:    void rotate(vector<vector<int>&a...

2018-05-15 14:13:58

阅读数:23

评论数:0

20. Valid Parentheses

/*1. 第一个字符入栈2. 第二个字符看看和栈的top是否匹配,如果匹配,出栈。如果不匹配,入栈。3. 循环1,24. 栈空,整体匹配,否则,整体不匹配。*/class Solution {public:    bool isValid(string s) {        if(s.size(...

2018-05-15 13:55:37

阅读数:21

评论数:0

1. Two Sum

/*1. 一个unordered_map结构,key是nums[i],值是i2. 遍历nums[i],如果target-nums[i]不存在,把nums[i],i 插入到map中去,如果找到,返回结果。*/class Solution {public:    vector<i...

2018-05-15 13:50:50

阅读数:22

评论数:0

200. Number of Islands

/*1. 找到一个grid[i][j]==1的节点,2. 把它置位23. 从这个节点向外扩展,(递归),建岛完成。4. 找第二个grid[i][j] == 1的节点,转2.*/class Solution {public:    int numIslands(vector<v...

2018-05-15 13:46:38

阅读数:21

评论数:0

763. Partition Labels

class Solution {public:    vector<int> partitionLabels(string S) {        vector<int> ret;        help(re...

2018-05-15 13:40:14

阅读数:24

评论数:0

提示
确定要删除当前文章?
取消 删除