PikachuBLOG


  • 首页

  • 分类

  • 归档

  • 标签

  • 搜索

27. Remove Element

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

27. Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
The order of elements can be changed. It doesn’t matter what you leave beyond the new length.

Example:
Given input array nums = [3,2,2,3], val = 3
Your function should return length = 2, with the first two elements of nums being 2.

阅读全文 »

26. Remove Duplicates from Sorted Array

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

26. Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.

For example,
Given input array nums = [1,1,2],

Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn’t matter what you leave beyond the new length.

阅读全文 »

25. Reverse Nodes in k-Group

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

25. Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left - out nodes in the end should remain as it is.
You may not alter the values in the nodes, only nodes itself may be changed.
Only constant memory is allowed.

For example,

Given this linked list : 1->2->3->4->5
For k = 2, you should return : 2->1->4->3->5
For k = 3, you should return : 3->2->1->4->5

阅读全文 »

24. Swap Nodes in Pairs

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

24. Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.

For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.

Your algorithm should use only constant space.You may not modify the values in the list, only nodes itself can be changed.

阅读全文 »

23. Merge k Sorted Lists

发表于 2017-07-08 | 分类于 LeetCode | 阅读次数
字数统计 1,742 | 阅读时长 9

23. Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list.Analyze and describe its complexity.

题意:

  合并K个排序的链表并将其返回为一个排序列表,并分析其复杂性。

阅读全文 »

22. Generate Parentheses

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

22. Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well - formed parentheses.

For example, given n = 3, a solution set is :
“((()))”, “(()())”, “(())()”, “()(())”, “()()()”

阅读全文 »

21. Merge Two Sorted Lists

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

21. Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

题意:

  合并两个排序链表为一个链表,合并后链表是有序链表。

阅读全文 »

20. Valid Parentheses

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

20. Valid Parentheses

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid.
The brackets must close in the correct order, “()” and “()[]{}” are all valid but “(]” and “([)]” are not.

阅读全文 »

19. Remove Nth Node From End of List

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

19. Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.

For example:
Given linked list : 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.

Note :
​ Given n will always be valid.
​ Try to do this in one pass.

阅读全文 »

17. Letter Combinations of a Phone Number

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

17. Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below.

Input:Digit string “23”
Output: [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf”].

Note:
Although the above answer is in lexicographical order, your answer could be in any order you want.

阅读全文 »
1…14151617
CodePikachu

CodePikachu

技术随笔

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