随笔分类 - Google
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product. Example For example, given the array [2,3
阅读全文
摘要:Flatten a binary tree to a fake "linked list" in pre-order traversal. Here we use the right pointer in TreeNode as the next pointer in ListNode. For e
阅读全文
摘要:Intersection of Two Arrays Given two arrays, write a function to compute their intersection. Example Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], retur
阅读全文
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist
阅读全文
摘要:Word Search I 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
阅读全文
摘要:Question: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways
阅读全文
摘要:Question: Find the longest sub-string without repeating characters. For example, if the given string is "abcdcefg", the longest sub-string is "dcefg".
阅读全文
摘要:Word Break I 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 dictionar
阅读全文
摘要:Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. The key part is i <= haystack.length() - nee
阅读全文
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan
阅读全文
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read off
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings. For instance: ["ab", "bc"] returns ""; ["a", "ab"] re
阅读全文
摘要:问题: 所谓 anagram, 就是两个词所用的字母及其个数都是一样的,但是,字母的位置不一样。比如 abcc 和 cbca 就是 anagram. 分析: 判断的方法比较简单,先把单个字母(字符)转成整数,然后利用了hashtable+计数器的原理进行判断。 转载请注明出处。
阅读全文
摘要:Given a digit string, return all possible letter combinations that the number could represent. Example Given "23" Return ["ad", "ae", "af", "bd", "be"
阅读全文
摘要: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: "
阅读全文
摘要: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
阅读全文
摘要:Subsets I Given a set of distinct integers, return all possible subsets. Notice Elements in a subset must be in non-descending order. The solution set
阅读全文

浙公网安备 33010602011771号