随笔分类 - leetcode
1
摘要:Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:On...
阅读全文
摘要:Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictio...
阅读全文
摘要:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Re...
阅读全文
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, "A man, a pl...
阅读全文
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For exampl...
阅读全文
摘要:Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that s...
阅读全文
摘要:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path...
阅读全文
摘要:Sort a linked list in O(n log n) time using constant space complexity.C++/** * Definition for singly-linked list. * struct ListNode { ...
阅读全文
摘要:Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear...
阅读全文
摘要:Given an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a ...
阅读全文
摘要:Given a singly linked list L: L 0→L 1→…→L n-1→L n, reorder it to: L 0→L n →L 1→L n-1→L 2→L n-2→…You must do this in-place without alte...
阅读全文
摘要:Given a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to...
阅读全文
摘要:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previo...
阅读全文
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals ...
阅读全文
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example: Given the below bin...
阅读全文
摘要:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1],...
阅读全文
摘要:Given an index k, return the k th row of the Pascal's triangle.For example, given k = 3, Return[1,3,3,1].Note: Could you optimize your...
阅读全文
摘要:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning o...
阅读全文
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down t...
阅读全文
摘要:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindro...
阅读全文
1