随笔分类 -  ~~Leetcode~~

1 2 3 4 5 ··· 7 下一页
摘要:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?题目意思: 给定一个单链表,判断它是不是回文串 进一步思考: ... 阅读全文
posted @ 2015-08-02 17:12 OpenSoucre 阅读(305) 评论(0) 推荐(0)
摘要:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ... 阅读全文
posted @ 2015-08-02 15:50 OpenSoucre 阅读(268) 评论(0) 推荐(0)
摘要:Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur... 阅读全文
posted @ 2015-08-02 15:44 OpenSoucre 阅读(293) 评论(0) 推荐(0)
摘要:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota... 阅读全文
posted @ 2015-07-07 19:43 OpenSoucre 阅读(1005) 评论(0) 推荐(0)
摘要:Given an integer, write a function to determine if it is a power of two.题目意思: 给定一个整数,判断是否是2的幂解题思路: 如果一个整数是2的幂,则二进制最高位为1,减去1后则最高位变为0,后面全部是1,相与判读是否为零,... 阅读全文
posted @ 2015-07-07 16:21 OpenSoucre 阅读(178) 评论(0) 推荐(0)
摘要:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o... 阅读全文
posted @ 2015-07-07 16:09 OpenSoucre 阅读(302) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2014-10-08 16:44 OpenSoucre 阅读(181) 评论(0) 推荐(0)
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"Corner Cases:Did you con... 阅读全文
posted @ 2014-07-15 22:04 OpenSoucre 阅读(143) 评论(0) 推荐(0)
摘要:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文
posted @ 2014-07-15 20:40 OpenSoucre 阅读(193) 评论(0) 推荐(0)
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA... 阅读全文
posted @ 2014-07-15 12:13 OpenSoucre 阅读(239) 评论(0) 推荐(0)
摘要:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2014-07-08 22:17 OpenSoucre 阅读(363) 评论(0) 推荐(0)
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ... 阅读全文
posted @ 2014-07-08 21:46 OpenSoucre 阅读(221) 评论(0) 推荐(0)
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ... 阅读全文
posted @ 2014-07-08 21:04 OpenSoucre 阅读(241) 评论(0) 推荐(0)
摘要: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 on... 阅读全文
posted @ 2014-07-07 21:26 OpenSoucre 阅读(162) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2014-07-07 20:59 OpenSoucre 阅读(198) 评论(0) 推荐(0)
摘要:Given a collection of 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,... 阅读全文
posted @ 2014-07-05 21:22 OpenSoucre 阅读(158) 评论(0) 推荐(0)
摘要:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.class Solution {public: ... 阅读全文
posted @ 2014-07-05 21:02 OpenSoucre 阅读(147) 评论(0) 推荐(0)
摘要:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc... 阅读全文
posted @ 2014-07-05 20:42 OpenSoucre 阅读(164) 评论(0) 推荐(0)
摘要:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文
posted @ 2014-07-05 18:35 OpenSoucre 阅读(197) 评论(0) 推荐(0)
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2014-07-05 17:32 OpenSoucre 阅读(176) 评论(0) 推荐(0)

1 2 3 4 5 ··· 7 下一页