- 博客(17)
- 收藏
- 关注
原创 Next Permutation
题目: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest
2015-12-17 20:10:31 336
原创 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. 思路: 从最前面开始比较,每次都是最一开始的进行比较,但要注意比较过程中检查是否有链表已经为空。
2015-12-17 19:49:49 367
原创 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
2015-12-15 20:51:54 311
原创 Valid Sudoku
题目: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partiall
2015-12-15 20:46:24 346
原创 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 a
2015-12-09 09:25:55 417
原创 Container With 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, suc
2015-12-06 22:22:21 412
原创 Add Two Numbers
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
2015-12-05 23:50:32 357
原创 First Missing Positive
题目:Given an unsorted integer array, find the first missing positive integer.
2015-12-05 23:50:04 314
原创 Sudoku Solver
题目:Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be only one unique solution. A s
2015-12-05 08:02:53 402
原创 Search in Rotated Sorted Array
题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array
2015-12-04 00:17:29 366
原创 Substring with Concatenation of All Words
题目:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once a
2015-12-03 23:56:02 329
原创 Median of Two Sorted Arrays
题目:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 思路: 本题如此讲解,设两个数组:a[
2015-12-02 23:35:25 370
原创 Palindrome Number
题目:Determine whether an integer is a palindrome. Do this without extra space. 思路: 一个技巧就是先计算出一共几位数,对应后面几个零; 接下来就是循环,首先除以div,在%10,就是最左边最右边的数字,判断两者是否相等。 不等,直接返回。 代码: class Solution { public:
2015-12-02 23:27:35 330
原创 Word Ladder II
题目:Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that: Only one letter can be changed at a time
2015-12-01 23:55:25 358
原创 Word Ladder
题目:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that: Only one letter can be changed at
2015-12-01 23:51:17 360
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人