Skip to content

Commit

Permalink
adjust the comment length
Browse files Browse the repository at this point in the history
  • Loading branch information
haoel committed Oct 21, 2014
1 parent ad62b9d commit 4cda310
Show file tree
Hide file tree
Showing 73 changed files with 220 additions and 120 deletions.
3 changes: 2 additions & 1 deletion src/3Sum/3Sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* 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.
* 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.
*
* Note:
*
Expand Down
4 changes: 3 additions & 1 deletion src/3SumClosest/3SumClosest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

/**********************************************************************************
*
* 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.
* 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.
*
* For example, given array S = {-1 2 1 -4}, and target = 1.
*
Expand Down
3 changes: 2 additions & 1 deletion src/4Sum/4Sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* 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.
* 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.
*
* Note:
*
Expand Down
12 changes: 8 additions & 4 deletions src/LRUCache/LRUCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

/**********************************************************************************
*
* Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.
*
* get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
* 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.
* Design and implement a data structure for Least Recently Used (LRU) cache.
* It should support the following operations: get and set.
*
* get(key) - Get the value (will always be positive) of the key if the key exists
* in the cache, otherwise return -1.
*
* 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.
*
**********************************************************************************/

Expand Down
4 changes: 3 additions & 1 deletion src/addTwoNumbers/addTwoNumbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

/**********************************************************************************
*
* 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.
* 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.
*
* Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
* Output: 7 -> 0 -> 8
Expand Down
3 changes: 2 additions & 1 deletion src/balancedBinaryTree/balancedBinaryTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*
* Given a binary tree, determine if it is height-balanced.
*
* 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.
* 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.
*
*
**********************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
*
* Say you have an array for which the ith element is the price of a given stock on day i.
*
* 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).
* 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).
*
**********************************************************************************/

Expand Down
3 changes: 2 additions & 1 deletion src/bestTimeToBuyAndSellStock/bestTimeToBuyAndSellStock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*
* Say you have an array for which the ith element is the price of a given stock on day i.
*
* If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
* If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
* design an algorithm to find the maximum profit.
*
**********************************************************************************/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*
* OJ's Binary Tree Serialization:
*
* The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.
* The serialization of a binary tree follows a level order traversal, where '#' signifies
* a path terminator where no node exists below.
*
* Here's an example:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
* Given a binary tree, return the bottom-up level order traversal of its nodes' values.
* (ie, from left to right, level by level from leaf to root).
*
* For example:
* Given binary tree {3,9,20,#,#,15,7},
Expand All @@ -27,7 +28,8 @@
*
* OJ's Binary Tree Serialization:
*
* The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.
* The serialization of a binary tree follows a level order traversal, where '#' signifies
* a path terminator where no node exists below.
*
* Here's an example:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
* Given a binary tree, return the level order traversal of its nodes' values.
* (ie, from left to right, level by level).
*
* For example:
* Given binary tree {3,9,20,#,#,15,7},
Expand All @@ -27,7 +28,8 @@
*
* OJ's Binary Tree Serialization:
*
* The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.
* The serialization of a binary tree follows a level order traversal, where '#' signifies
* a path terminator where no node exists below.
*
* Here's an example:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
* Given a binary tree, return the zigzag level order traversal of its nodes' values.
* (ie, from left to right, then right to left for the next level and alternate between).
*
* For example:
* Given binary tree {3,9,20,#,#,15,7},
Expand All @@ -27,7 +28,8 @@
*
* OJ's Binary Tree Serialization:
*
* The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.
* The serialization of a binary tree follows a level order traversal,
* where '#' signifies a path terminator where no node exists below.
*
* Here's an example:
*
Expand Down
10 changes: 6 additions & 4 deletions src/combinationSum/combinationSum.II.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

/**********************************************************************************
*
* Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
* Given a collection of candidate numbers (C) and a target number (T), find all
* unique combinations in C where the candidate numbers sums to T.
*
* Each number in C may only be used once in the combination.
*
* Note:
*
* All numbers (including target) will be positive integers.
* Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak).
* The solution set must not contain duplicate combinations.
* > All numbers (including target) will be positive integers.
* > Elements in a combination (a1, a2, … , ak) must be in non-descending order.
* (ie, a1 ≤ a2 ≤ … ≤ ak).
* > The solution set must not contain duplicate combinations.
*
* For example, given candidate set 10,1,2,7,6,1,5 and target 8,
* A solution set is:
Expand Down
3 changes: 2 additions & 1 deletion src/combinationSum/combinationSum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.
* Given a set of candidate numbers (C) and a target number (T), find all unique combinations
* in C where the candidate numbers sums to T.
*
* The same repeated number may be chosen from C unlimited number of times.
*
Expand Down
5 changes: 4 additions & 1 deletion src/containerWithMostWater/containerWithMostWater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

/**********************************************************************************
*
* Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
* Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).
* n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0).
*
* Find two lines, which together with x-axis forms a container, such that the container contains the most water.
*
* Note: You may not slant the container.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
* Given a singly linked list where elements are sorted in ascending order,
* convert it to a height balanced BST.
*
**********************************************************************************/

Expand Down
3 changes: 2 additions & 1 deletion src/copyListWithRandomPointer/copyListWithRandomPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* 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.
* 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 of the list.
*
Expand Down
4 changes: 3 additions & 1 deletion src/distinctSubsequences/distinctSubsequences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
*
* Given a string S and a string T, count the number of distinct subsequences of T in S.
*
* A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).
* A subsequence of a string is a new string which is formed from the original string
* by deleting some (can be none) of the characters without disturbing the relative positions
* of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).
*
* Here is an example:
* S = "rabbbit", T = "rabbit"
Expand Down
3 changes: 2 additions & 1 deletion src/editDistance/editDistance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)
* Given two words word1 and word2, find the minimum number of steps required to
* convert word1 to word2. (each operation is counted as 1 step.)
*
* You have the following 3 operations permitted on a word:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
* \
* 6
*
* click to show hints.
*
* Hints:
* If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal.
*
* If you notice carefully in the flattened tree, each node's right child points to
* the next node of a pre-order traversal.
*
**********************************************************************************/

Expand Down
3 changes: 2 additions & 1 deletion src/gasStation/gasStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*
* There are N gas stations along a circular route, where the amount of gas at station i is gas[i].
*
* You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations.
* You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
* its next station (i+1). You begin the journey with an empty tank at one of the gas stations.
*
* Return the starting gas station's index if you can travel around the circuit once, otherwise return -1.
*
Expand Down
3 changes: 2 additions & 1 deletion src/grayCode/grayCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*
* The gray code is a binary numeral system where two successive values differ in only one bit.
*
* Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.
* Given a non-negative integer n representing the total number of bits in the code,
* print the sequence of gray code. A gray code sequence must begin with 0.
*
* For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:
*
Expand Down
3 changes: 2 additions & 1 deletion src/jumpGame/jumpGame.II.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
* For example:
* Given array A = [2,3,1,1,4]
*
* The minimum number of jumps to reach the last index is 2. (Jump 1 step from index 0 to 1, then 3 steps to the last index.)
* The minimum number of jumps to reach the last index is 2.
* (Jump 1 step from index 0 to 1, then 3 steps to the last index.)
*
*
**********************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.
* Given n non-negative integers representing the histogram's bar height where the width of each bar is 1,
* find the area of largest rectangle in the histogram.
*
* Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3].
*
Expand Down
3 changes: 2 additions & 1 deletion src/lengthOfLastWord/lengthOfLastWord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
* Given a string s consists of upper/lower-case alphabets and empty space characters ' ',
* return the length of last word in the string.
*
* If the last word does not exist, return 0.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

/**********************************************************************************
*
* Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
* Given a string S, find the longest palindromic substring in S.
* You may assume that the maximum length of S is 1000,
* and there exists one unique longest palindromic substring.
*
**********************************************************************************/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

/**********************************************************************************
*
* Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
* Given a string, find the length of the longest substring without repeating characters.
* For example, the longest substring without repeating letters for "abcabcbb" is "abc",
* which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
*
**********************************************************************************/

Expand Down
6 changes: 4 additions & 2 deletions src/longestValidParentheses/longestValidParentheses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

/**********************************************************************************
*
* Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
* Given a string containing just the characters '(' and ')',
* find the length of the longest valid (well-formed) parentheses substring.
*
* For "(()", the longest valid parentheses substring is "()", which has length = 2.
*
* Another example is ")()())", where the longest valid parentheses substring is "()()", which has length = 4.
* Another example is ")()())", where the longest valid parentheses substring is "()()",
* which has length = 4.
*
*
**********************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions src/maximalRectangle/maximalRectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

/**********************************************************************************
*
* Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
*
* Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle
* containing all ones and return its area.
*
**********************************************************************************/

Expand Down
3 changes: 2 additions & 1 deletion src/maximumDepthOfBinaryTree/maximumDepthOfBinaryTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*
* Given a binary tree, find its maximum depth.
*
* The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
* The maximum depth is the number of nodes along the longest path from the root node
* down to the farthest leaf node.
*
**********************************************************************************/

Expand Down
3 changes: 2 additions & 1 deletion src/maximumProductSubarray/maximumProductSubarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

/**********************************************************************************
*
* Find the contiguous subarray within an array (containing at least one number) which has the largest product.
* Find the contiguous subarray within an array (containing at least one number)
* which has the largest product.
*
* For example, given the array [2,3,-2,4],
* the contiguous subarray [2,3] has the largest product = 6.
Expand Down
Loading

0 comments on commit 4cda310

Please sign in to comment.