持续更新中(* ॑ᐜ ॑*)(* ॑ᐜ ॑*)
Sliding Window (滑动窗口)
寻找符合条件的最短子字符串——SLIDING WINDOW
Backtracking (回溯法)
数组排列组合问题——BACKTRACKING
Dynamic
leetcode第二题
题目:
给定两个非空链表来表示两个非负整数。位数按照逆序方式存储,它们的每个节点只存储单个数字。将两数相加返回一个新的链表。
你可以假设除了数字 0 之外,这两个数字都不会以零开头。
源码(使用Java语言)
/**
* Definition for singly-lin
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 a
这是LeetCode里的第25道题。
题目要求:
给出一个链表,每 k 个节点一组进行翻转,并返回翻转后的链表。
k 是一个正整数,它的值小于或等于链表的长度。如果节点总数不是 k 的整数倍,那么将最后剩余节点保持原有顺序。
示例 :
给定这个链表:1->2->3->4->
Add Digits
题目描述:
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the p
题目:Sort List
Sort a linked list in O(n log n) time using constant space complexity
看题目有两个要求:1)时间复杂度为O(nlogn);2)空间复杂度为常数,即不能增设额外的
Description
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input w
Description
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays. The overall run time c
Description
Given a string, find the length of the longest substring without repeating characters.
Example
Given "abcabcbb", the answer is "abc", whic
Description
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their
Description
Write a function to find the longest common prefix string amongst an array of strings.
思路
最长的公共前缀,所以,先找出前两个的最长前缀,然后再和后面的比,在比的过程中,记录最小的串的长度
Description
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
思路
这个也没啥好说的吧,首先搞清楚罗马数字是个什么鬼?
基
Description
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
思路
这个也没啥好说的吧,首先搞清楚罗马数字是个什么鬼?
基
Description
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that t
Description
Implement regular expression matching with support for '.' and '*'.
Example
'.' Matches any single character.
'*' Matches zero or more of
Description
Determine whether an integer is a palindrome. Do this without extra space.
Example
Some hints:
Could negative integers be palindromes? (ie
Description
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do no
Description
Reverse digits of an integer.
Example
Example1: x = 123, return 321
Example2: x = -123, return -321
Note:
The input is assumed to be a 32
Description
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
Description
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example
Example1: