wind-liang / leetcode Goto Github PK
View Code? Open in Web Editor NEWleetcode 顺序刷题,详细通俗题解,with JAVA
Home Page: https://leetcode.wang
leetcode 顺序刷题,详细通俗题解,with JAVA
Home Page: https://leetcode.wang
此时 3 位置的数值对应为数组下标是 0 的值,1 位置的值对应数组下标是 5 的值。任意位置的对应规则是什么呢?0 -> 4, 1 - > 5,4 ->1,就是就是 (位置 + 偏移 % 数组的长度)。这里就是加上 4 模 7。
其中,(位置 + 偏移 % 数组的长度)
应该改成(位置 + 偏移)% 数组的长度
/*
链表反序存储时,是不是可以使用堆栈?
*/
type stack []int
func (s *stack) push(item int) {
(*s) = append((*s), item)
}
func (s *stack) pop() int {
item := (*s)[len(*s)-1]
(*s) = (*s)[:len(*s)-1]
return item
}
func (s stack) depth() int {
return len(s)
}
func addTwoReverseNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
sumStack := make(stack, 0)
carryStack := make(stack, 0)
carry := 0
for l1 != nil || l2 != nil {
l1val := 0
l2val := 0
if l1 != nil {
l1val = l1.Val
l1 = l1.Next
}
if l2 != nil {
l2val = l2.Val
l2 = l2.Next
}
sum := l1val + l2val
carry = sum / 10
sumStack.push(sum % 10)
carryStack.push(carry)
}
sumList := new(ListNode)
isFirst := true
carry = 0
for sumStack.depth() != 0 || carryStack.depth() != 0 || carry != 0 {
curSum := 0
curCarry := 0
curNode := new(ListNode)
if sumStack.depth() != 0 {
curSum = sumStack.pop()
}
if !isFirst && carryStack.depth() != 0 {
curCarry = carryStack.pop()
}
isFirst = false
curVal := (curSum + curCarry + carry)
carry = curVal / 10
curNode.Val = curVal % 10
curNode.Next = sumList.Next
sumList.Next = curNode
}
return sumList.Next
}
https://github.com/wind-liang/leetcode/blob/master/leetCode-5-Longest-Palindromic-Substring.md
通常 i 是行 j 是列。 你在图中倒过来不适应。Thanks
https://leetcode.wang/ 直接搜索题号无法显示对应题目。。。
如题,应该是笔误。
也不算 issue 就是
不確定文本寫成時是否 AC,但目前解法一會超時,建議注釋一下
我发现在网站上有些题目的名字带*号,例如题4,这是为什么?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.