# 字典树trie-tree纯c语言leetcode实现模板

leetcode c语言trie树前缀实现 应对leetcode大部分字符串快速查找，插入，前缀匹配 该模板方便leetcode后续做题 前缀树主要是通过共享前缀的方式，保证大部分拥有共同前缀的字符串能够方便的被找到，查询。 #define N 27 struct Trie{ struct Trie *ch[N]; bool is_end; }; typedef struct Trie Trie; …

# [leetcode题解]52. N-Queens II

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the number of disti …

# [leetcode题解] 51. N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions t …

# [leetcode题解]28. Implement strStr()

Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = “hello”, needle = “ll” Output: …

# [leetcode题解]027.Remove Element

Given an array nums and a value val, remove all instances of that value in-placeand return the new length. Do not allocate extra space for another array, you must do this by m …

# [leetcode题解]026.Remove Duplicates from Sorted Array

Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you …

# [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: [   “((()))”,   “(()()) …

# [leetcode题解]20.valid parentheses

Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if t …

# [leetcode题解]17.4sum

Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c+ d = target? Find all unique quadruplets in the array which gives the sum of targ …

# [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 button …

# [leetcode题解]15. 3sum

Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets …

# 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 “”. Example 1: Input: [“flower”,”flow”,”fli …

# [leetcode题解]9. Palindrome Number

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Outpu …

# [leetcode题解]8. String to Integer (atoi)

Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, sta …

# [leetcode题解]7. Reverse Integer

Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an …

# [leetcode题解]6. ZigZag Conversion

The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H …

# [leetcode题解]03.Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”, which the length is …

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two …

# [leetcode题解]001.Two Sum

You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, ret …

# leetcode题解刷题汇总

leetcode题目不断刷新，大家也都一直在刷，本文记录作者刷题记录，一直更新，权当抛砖引玉，欢迎大家一块交流学习。如果各位leetcoder发现题解有问题，欢迎指正交流，也希望大家可以提出更新颖的解题方法。新建leetcode算法交流群259150720，欢迎leetcoder进群交流。 0001 Two Sum array Easy 0002 Add Two Numbers linked li …

# [leetcode题解]547. Friend Circles,朋友圈

There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a  …

# [leetcode题解]859. Buddy Strings

Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B.   Example 1: …

# [leetcode题解]130. Surrounded Regions

Given a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’. A region is captured by flipping all &# …