PikachuBLOG


  • 首页

  • 分类

  • 归档

  • 标签

  • 搜索

53. Maximum Subarray

发表于 2017-07-25 | 分类于 LeetCode | 阅读次数
字数统计 371 | 阅读时长 2

53. Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.

For example, given the array [-2,1,-3,4,-1,2,1,-5,4],
the contiguous subarray [4,-1,2,1] has the largest sum = 6.

More practice:
If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.

阅读全文 »

52. N-Queens II

发表于 2017-07-24 | 分类于 LeetCode | 阅读次数
字数统计 1,257 | 阅读时长 6

52. N - Queens II

Follow up for N-Queens problem.

52-8-queens

Now, instead outputting board configurations, return the total number of distinct solutions.

阅读全文 »

51. N-Queens

发表于 2017-07-22 | 分类于 LeetCode | 阅读次数
字数统计 3,186 | 阅读时长 14

51. N - Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens puzzle.
Each solution contains a distinct board configuration of the n-queens’ placement, where ‘Q’ and ‘.’ both indicate a queen and an empty space respectively.

For example,
There exist two distinct solutions to the 4-queens puzzle:
[
  [“.Q..”, // Solution 1
  “…Q”,
  “Q…”,
  “..Q.”],

  [“..Q.”, // Solution 2
  Q…”,
  “…Q”,
  “.Q..”]
]

阅读全文 »

49. Group Anagrams

发表于 2017-07-22 | 分类于 LeetCode | 阅读次数
字数统计 495 | 阅读时长 3

49. Group Anagrams

Given an array of strings, group anagrams together.

For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],
Return :
  [
    [“ate”, “eat”, “tea”],
    [“nat”, “tan”],
    [“bat”]
​ ]
Note: All inputs will be in lower - case.

阅读全文 »

48. Rotate Image

发表于 2017-07-21 | 分类于 LeetCode | 阅读次数
字数统计 674 | 阅读时长 3

48. Rotate Image

You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).

Follow up:
 Could you do this in-place?

阅读全文 »

47. Permutations II

发表于 2017-07-21 | 分类于 LeetCode | 阅读次数
字数统计 533 | 阅读时长 3

47. Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations.

For example,
[1,1,2] have the following unique permutations:
[
  [1,1,2],
  [1,2,1],
  [2,1,1]
]

阅读全文 »

46. Permutations

发表于 2017-07-20 | 分类于 LeetCode | 阅读次数
字数统计 824 | 阅读时长 4

46. Permutations

Given a collection of distinct numbers, return all possible permutations.

For example,
[1,2,3] have the following permutations:
[
 [1,2,3],
 [1,3,2],
 [2,1,3],
 [2,3,1],
 [3,1,2],
 [3,2,1]
]

阅读全文 »

43. Multiply Strings

发表于 2017-07-20 | 分类于 LeetCode | 阅读次数
字数统计 813 | 阅读时长 4

43. Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string.

Note:
  The numbers can be arbitrarily large and are non-negative.
  Converting the input string to integer is NOT allowed.
  You should NOT use internal library such as BigInteger.

阅读全文 »

42. Trapping Rain Water

发表于 2017-07-20 | 分类于 LeetCode | 阅读次数
字数统计 492 | 阅读时长 2

42. Trapping Rain Water(hasDone)

Given n non - negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.

For example,
Given[0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1], return 6.
42-rainwatertrap
The above elevation map is represented by array[0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1].In this case, 6 units of rain water(blue section) are being trapped.

阅读全文 »

40. Combination Sum II

发表于 2017-07-19 | 分类于 LeetCode | 阅读次数
字数统计 558 | 阅读时长 3

40. Combination Sum II

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.
  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:
[
  [1, 7],
  [1, 2, 5],
  [2, 6],
  [1, 1, 6]
]

阅读全文 »
1…121314…17
CodePikachu

CodePikachu

技术随笔

168 日志
5 分类
7 标签
RSS
GitHub Twitter 微博 知乎
0%
© 2015 - 2020 CodePikachu
博客全站共123.3k字
本站访客数:
由 Hexo 强力驱动
主题 - NexT.Pisces