10000 add the problem content into source file · yaosj2k/leetcode@ad62b9d · GitHub
[go: up one dir, main page]

Skip to content

Commit ad62b9d

Browse files
committed
add the problem content into source file
1 parent 512b39d commit ad62b9d

File tree

153 files changed

+2449
-1
lines changed
  • searchForRange
  • searchInRotatedSortedArray
  • searchInsertPosition
  • setMatrixZeroes
  • simplifyPath
  • singleNumber
  • sortColors
  • sortList
  • spiralMatrix
  • sqrt
  • strStr
  • stringToIntegerAtoi
  • subsets
  • substringWithConcatenationOfAllWords
  • sudokuSolver
  • sumRootToLeafNumber
  • surroundedRegions
  • swapNodesInPairs
  • symmetricTree
  • textJustification
  • trappingRainWater
  • triangle
  • twoSum
  • uniqueBinarySearchTrees
  • uniquePaths
  • validNumber
  • validPalindrome
  • validParentheses
  • validSudoku
  • validateBinarySearchTree
  • wildcardMatching
  • wordBreak
  • wordLadder
  • wordSearch
  • zigZagConversion
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    153 files changed

    +2449
    -1
    lines changed

    src/3Sum/3Sum.cpp

    Lines changed: 18 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,24 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-07-22
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
    8+
    *
    9+
    * Note:
    10+
    *
    11+
    * Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
    12+
    * The solution set must not contain duplicate triplets.
    13+
    *
    14+
    * For example, given array S = {-1 0 1 2 -1 -4},
    15+
    *
    16+
    * A solution set is:
    17+
    * (-1, 0, 1)
    18+
    * (-1, -1, 2)
    19+
    *
    20+
    *
    21+
    **********************************************************************************/
    22+
    523
    #include <stdio.h>
    624
    #include <iostream>
    725
    #include <vector>

    src/3SumClosest/3SumClosest.cpp

    Lines changed: 11 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,17 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-07-03
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
    8+
    *
    9+
    * For example, given array S = {-1 2 1 -4}, and target = 1.
    10+
    *
    11+
    * The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
    12+
    *
    13+
    *
    14+
    **********************************************************************************/
    15+
    516
    #include <stdio.h>
    617
    #include <stdlib.h>
    718
    #include <iostream>

    src/4Sum/4Sum.cpp

    Lines changed: 19 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,25 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-07-03
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
    8+
    *
    9+
    * Note:
    10+
    *
    11+
    * Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d)
    12+
    * The solution set must not contain duplicate quadruplets.
    13+
    *
    14+
    * For example, given array S = {1 0 -1 0 -2 2}, and target = 0.
    15+
    *
    16+
    * A solution set is:
    17+
    * (-1, 0, 0, 1)
    18+
    * (-2, -1, 1, 2)
    19+
    * (-2, 0, 0, 2)
    20+
    *
    21+
    *
    22+
    **********************************************************************************/
    23+
    524
    #include <iostream>
    625
    #include <vector>
    726
    #include <algorithm>

    src/LRUCache/LRUCache.cpp

    Lines changed: 10 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,16 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-10-12
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.
    8+
    *
    9+
    * get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
    10+
    * set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.
    11+
    *
    12+
    *
    13+
    **********************************************************************************/
    14+
    515
    #include <stdlib.h>
    616
    #include <time.h>
    717
    #include <iostream>

    src/addBinary/addBinary.cpp

    Lines changed: 12 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,18 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-07-05
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Given two binary strings, return their sum (also a binary string).
    8+
    *
    9+
    * For example,
    10+
    * a = "11"
    11+
    * b = "1"
    12+
    * Return "100".
    13+
    *
    14+
    *
    15+
    **********************************************************************************/
    16+
    517
    #include <iostream>
    618
    #include <string>
    719
    using namespace std;

    src/addTwoNumbers/addTwoNumbers.cpp

    Lines changed: 9 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,15 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-06-18
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
    8+
    *
    9+
    * Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
    10+
    * Output: 7 -> 0 -> 8
    11+
    *
    12+
    **********************************************************************************/
    13+
    514
    /**
    615
    * Definition for singly-linked list.
    716
    * struct ListNode {

    src/anagrams/anagrams.cpp

    Lines changed: 8 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,14 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-07-18
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Given an array of strings, return all groups of strings that are anagrams.
    8+
    *
    9+
    * Note: All inputs will be in lower-case.
    10+
    *
    11+
    **********************************************************************************/
    12+
    513
    class Solution {
    614
    public:
    715
    vector<string> anagrams(vector<string> &strs) {

    src/balancedBinaryTree/balancedBinaryTree.cpp

    Lines changed: 9 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,15 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-06-28
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Given a binary tree, determine if it is height-balanced.
    8+
    *
    9+
    * For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.
    10+
    *
    11+
    *
    12+
    **********************************************************************************/
    13+
    514
    /**
    615
    * Definition for binary tree
    716
    * struct TreeNode {

    src/bestTimeToBuyAndSellStock/bestTimeToBuyAndSellStock.II.cpp

    Lines changed: 8 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,14 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-06-18
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Say you have an array for which the ith element is the price of a given stock on day i.
    8+
    *
    9+
    * Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
    10+
    *
    11+
    **********************************************************************************/
    12+
    513
    class Solution {
    614
    public:
    715
    int maxProfit(vector<int> &prices) {

    src/bestTimeToBuyAndSellStock/bestTimeToBuyAndSellStock.III.cpp

    Lines changed: 11 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2,6 +2,17 @@
    22
    // Author : Hao Chen
    33
    // Date : 2014-08-22
    44

    5+
    /**********************************************************************************
    6+
    *
    7+
    * Say you have an array for which the ith element is the price of a given stock on day i.
    8+
    *
    9+
    * Design an algorithm to find the maximum profit. You may complete at most two transactions.
    10+
    *
    11+
    * Note:
    12+
    * You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
    13+
    *
    14+
    **********************************************************************************/
    15+
    516

    617
    class Solution {
    718
    public:

    0 commit comments

    Comments
     (0)
    0