JinFei's Blog

Thinking will not overcome fear but action will.

[LeetCode]236. Lowest Common Ancestor of a Binary Tree

求树的公共祖先

题目描述 Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between t...

[LeetCode]139. Word Break

字符是否能够被拆分,dp

题目描述 Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. ...

[LeetCode]31. 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...

[LeetCode]3. Longest Substring Without Repeating Characters

最长不重复子串

题目描述 Given a string, find the length of the longest substring without repeating characters. Note: The input string length won’t exceed 1000. Example1: Input: “abcabcbb” Output: 3 Expl...

[LeetCode]17. Letter Combinations of a Phone Number

回溯,字母的组合

题目描述 Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone butt...

[LeetCode]14. Longest Common Prefix

水题

题目描述 Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. Example1: Input: [“flower”,”flow”,”fli...

[LeetCode]22. Generate Parentheses

递归

题目描述 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: Example: [ “((()))”, “(()()...

[LeetCode]49. Group Anagrams

同组字符串

题目描述 Given an array of strings, group anagrams together. Example1: Input: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Output: [ [“ate”,”eat”,”tea”], [“nat”,”tan”], [“bat”] ] ...

[LeetCode]字符串操作

string

本文是我转载,感谢作者!原文地址 https://github.com/shishujuan/data-structure-algorithms/blob/master/docs/ 这个系列是我多年前找工作时对数据结构和算法总结,其中有基础部分,也有各大公司的经典的面试题,最早发布在CSDN。现整理为一个系列给需要的朋友参考,如有错误,欢迎指正。本系列完整代码地址在 这里。 0 ...

[LeetCode]221. Maximal Square

dp

题目描述 Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. Example1: Input: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Outp...