- 博客(12)
- 收藏
- 关注
原创 Leetcode 19
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
2016-07-05 10:46:40
257
原创 Leetcode 26
Given a sorted array, remove the duplicates in place such that each element appear only once and returclass Solution {public: int removeDuplicates(vector& nums) { int size = nums.size();
2016-06-24 15:16:37
278
原创 Leetcode 88
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold add
2016-06-21 15:08:16
248
原创 Leetcode 144
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3]./** * Definition for
2016-06-21 15:04:49
388
原创 Leetcode 94
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2]./** * Definition fo
2016-06-21 14:55:12
258
原创 Leetcode 83
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3./** * Definition f
2016-04-11 14:54:22
309
原创 Leetcode 328
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in
2016-03-31 17:39:12
268
原创 Leetcode 13
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.class Solution {public: int romanToInt(string s) { int m=0,i=0,j=0,k=0; whil
2016-03-31 14:38:56
214
原创 Leetcode 217
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element
2016-03-30 11:46:14
200
原创 Leetcode 171
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ..
2016-03-30 11:44:09
290
原创 Leetcode 169
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element
2016-03-30 11:41:36
328
原创 Leetcode 206
Reverse a singly linked list.Recursion:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * };
2016-03-30 11:36:01
297
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅