PikachuBLOG


  • 首页

  • 分类

  • 归档

  • 标签

  • 搜索

216. Combination Sum III

发表于 2017-08-30 | 分类于 LeetCode | 阅读次数
字数统计 343 | 阅读时长 2

Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.

Example 1:
Input: k = 3, n = 7
Output:
[[1,2,4]]

Example 2:
Input: k = 3, n = 9
Output:
[[1,2,6], [1,3,5], [2,3,4]]

阅读全文 »

215. Kth Largest Element in an Array

发表于 2017-08-30 | 分类于 LeetCode | 阅读次数
字数统计 648 | 阅读时长 3

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.

For example,
Given [3,2,1,5,6,4] and k = 2, return 5.

Note:
You may assume k is always valid, 1 ≤ k ≤ array’s length.

阅读全文 »

214. Shortest Palindrome

发表于 2017-08-29 | 分类于 LeetCode | 阅读次数
字数统计 1,710 | 阅读时长 7

Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.

For example:
Given “aacecaaa”, return “aaacecaaa”.
Given “abcd”, return “dcbabcd”.

阅读全文 »

209. Minimum Size Subarray Sum

发表于 2017-08-28 | 分类于 LeetCode | 阅读次数
字数统计 758 | 阅读时长 4

Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.

For example, given the array [2,3,1,2,4,3] and s = 7,
the subarray [4,3] has the minimal length under the problem constraint.

阅读全文 »

206. Reverse Linked List

发表于 2017-08-28 | 分类于 LeetCode | 阅读次数
字数统计 377 | 阅读时长 2

Reverse a singly linked list.

Hint:
A linked list can be reversed either iteratively(迭代) or recursively(递归).Could you implement both ?

阅读全文 »

205. Isomorphic Strings

发表于 2017-08-28 | 分类于 LeetCode | 阅读次数
字数统计 401 | 阅读时长 2

Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.

All occurrences of a character must be replaced with another character while preserving the order of characters.No two characters may map to the same character but a character may map to itself.

For example,
Given “egg”, “add”, return true.
Given “foo”, “bar”, return false.
Given “paper”, “title”, return true.
Note:
You may assume both s and t have the same length.

阅读全文 »

204. Count Primes

发表于 2017-08-28 | 分类于 LeetCode | 阅读次数
字数统计 776 | 阅读时长 5

Count the number of prime numbers less than a non - negative number, n.

题意:

  计算小于n的非负数的质数的个数。

阅读全文 »

203. Remove Linked List Elements

发表于 2017-08-28 | 分类于 LeetCode | 阅读次数
字数统计 275 | 阅读时长 1

Remove all elements from a linked list of integers that have value val.

Example
Given : 1 – > 2 – > 6 – > 3 – > 4 – > 5 – > 6, val = 6
Return: 1 – > 2 – > 3 – > 4 – > 5

阅读全文 »

202. Happy Number

发表于 2017-08-28 | 分类于 LeetCode | 阅读次数
字数统计 438 | 阅读时长 2

Write an algorithm to determine if a number is “happy”.

A happy number is a number defined by the following process : Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.

Example : 19 is a happy number
​ 1^2 + 9^2 = 82
​ 8^2 + 2^2 = 68
​ 6^2 + 8^2 = 100
​ 1^2 + 0^2 + 0^2 = 1

阅读全文 »

199. Binary Tree Right Side View

发表于 2017-08-26 | 分类于 LeetCode | 阅读次数
字数统计 240 | 阅读时长 1

Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

1
2
3
4
5
6
7
8
9
For example:
Given the following binary tree,

1 <---
/ \
2 3 <---
\ \
5 4 <---
You should return [1, 3, 4].
阅读全文 »
1234…17
CodePikachu

CodePikachu

技术随笔

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