Redian新闻
>
coach的OUTLET网站上的包价格便宜很多,能买吗?
avatar
coach的OUTLET网站上的包价格便宜很多,能买吗?# Fashion - 美丽时尚
A*g
1
Leetcode上这题 reverse linked list II
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Google了一个解法,https://gist.github.com/eclipse9614/4757816
通过测试了
根据这个算法,模拟一下
如图,好像不是很对,肯定是我理解有问题
搞了一晚上了,太挫了!
avatar
I*s
2
妈妈也不会,想一起学。娃4岁。求安安猪推荐,谢了!
avatar
p*g
4
pass OJ
public ListNode reverseBetween(ListNode head, int m, int n) {
ListNode preHead = new ListNode(1), cur=head;
preHead.next = head;

for ( int i=0; icur = cur.next;
preHead = preHead.next;
}
ListNode tail = cur;
for ( int i=m; i<=n; i++) {
ListNode t = cur.next;
cur.next = preHead.next;
preHead.next = cur;
cur = t;
}
tail.next = cur;
return m==1? preHead.next:head;
}

【在 A******g 的大作中提到】
: Leetcode上这题 reverse linked list II
: Reverse a linked list from position m to n. Do it in-place and in one-pass.
: For example:
: Given 1->2->3->4->5->NULL, m = 2 and n = 4,
: return 1->4->3->2->5->NULL.
: Google了一个解法,https://gist.github.com/eclipse9614/4757816
: 通过测试了
: 根据这个算法,模拟一下
: 如图,好像不是很对,肯定是我理解有问题
: 搞了一晚上了,太挫了!

avatar
l*z
6
Coach has no outlet online store.
avatar
A*g
7
能解释一下算法吗,谢谢!
avatar
c*y
8
孩子们在美国学了围棋,容易找到朋友一起下棋吗?否则老缠着家长下棋咋办?或者整
天对这电脑下棋?
学国际象棋就很容易找到各种club,可以找朋友下棋了。
鉴于这一点,很优于是否学围棋。

【在 I**********s 的大作中提到】
: 妈妈也不会,想一起学。娃4岁。求安安猪推荐,谢了!
avatar
n*o
9
为什么最近几乎隔两天就来个人,拿着一看就不是真的的网站来问。。。
avatar
p*p
10
这人写的略乱……
按他的意思
mHead是m点那个
nNode是n后面那个
tmphead造出来不知道干嘛用的
这题用递归容易看

【在 A******g 的大作中提到】
: Leetcode上这题 reverse linked list II
: Reverse a linked list from position m to n. Do it in-place and in one-pass.
: For example:
: Given 1->2->3->4->5->NULL, m = 2 and n = 4,
: return 1->4->3->2->5->NULL.
: Google了一个解法,https://gist.github.com/eclipse9614/4757816
: 通过测试了
: 根据这个算法,模拟一下
: 如图,好像不是很对,肯定是我理解有问题
: 搞了一晚上了,太挫了!

avatar
s*t
11
就是一个爱好。其实从小到大花那么多时间金钱学琴有什么用?
avatar
l*7
12
小心地问一句,怎么“拿着一看就不是真的的网站”啊?

【在 n****o 的大作中提到】
: 为什么最近几乎隔两天就来个人,拿着一看就不是真的的网站来问。。。
avatar
c*t
13
赞图
这道题很难写对,
先试试把 reverse whole list 写对。
然后m to n 就是如何把头尾与原来的连接好了
还有就是多用变量。

【在 A******g 的大作中提到】
: Leetcode上这题 reverse linked list II
: Reverse a linked list from position m to n. Do it in-place and in one-pass.
: For example:
: Given 1->2->3->4->5->NULL, m = 2 and n = 4,
: return 1->4->3->2->5->NULL.
: Google了一个解法,https://gist.github.com/eclipse9614/4757816
: 通过测试了
: 根据这个算法,模拟一下
: 如图,好像不是很对,肯定是我理解有问题
: 搞了一晚上了,太挫了!

avatar
a*g
14
才4岁的小朋友,不着急,
等我正在编写的针对美国学校和孩子的围棋教材吧。
如果等不及了,
中文版本的《快乐学围棋》、《速成围棋》不错,
英文版本的 Level Up 也不错。
还有 ipad, smartphone 上都有好多免费的 app

【在 I**********s 的大作中提到】
: 妈妈也不会,想一起学。娃4岁。求安安猪推荐,谢了!
avatar
n*o
15
任何品牌的官方网站,你见过网站名字上加outlet字样的么。。。

【在 l******7 的大作中提到】
: 小心地问一句,怎么“拿着一看就不是真的的网站”啊?
avatar
A*g
16
谢谢大家指点! 用recursion果然很快写完了,而且比较容易看懂
avatar
a*g
17
你说得很对,围棋 club 少得太多太多了。
我前面也说了,围棋有竞技、爱好和教育方面的功能。
从教育角度,尤其是数学,围棋是其他棋类无法比;
从普及的角度,美国还差很远。这也是我正在做的。

【在 c********y 的大作中提到】
: 孩子们在美国学了围棋,容易找到朋友一起下棋吗?否则老缠着家长下棋咋办?或者整
: 天对这电脑下棋?
: 学国际象棋就很容易找到各种club,可以找朋友下棋了。
: 鉴于这一点,很优于是否学围棋。

avatar
d*h
18
this website.CS email is .***[email protected]
silly question.everything is so fake.

【在 l******7 的大作中提到】
: 小心地问一句,怎么“拿着一看就不是真的的网站”啊?
avatar
r*n
19
i know this is cheating, but can't you just swap the values of the two nodes
?
avatar
s*n
20
coach outlet没有网站
要买outlet货只能去实体店买
这种弄个名字很像的网站骗人很多,lz mm要多加训练自己会看
这就跟国内小说作者喜欢给自己弄个“金康”“全庸”的笔名卖武侠小说一样
avatar
l*b
21
反转整个链表貌似好写点, 反转 m, n需要有几个边角情况, leetcode上的解法挺好呀.
val c = List(1,2,3,4,5)
def rev(x:List[Int], t:List[Int]) : List[Int] = {
if (x.tail == Nil) return x ::: t
else rev(x.tail, x.head :: t)
}
rev(c, Nil)
得到
res1: List[Int] = List(5, 4, 3, 2, 1)
avatar
l*3
22
金庸新著。呵呵。
avatar
i*m
23
练习了
public ListNode reverseBetween(ListNode head, int m, int n) {
// Start typing your Java solution below
// DO NOT write main() function

int diff = n-m;
if (diff < 0 || m <= 0)
return null;
boolean flag = false;
ListNode cur = head;
ListNode prev = head;

while (m-- > 1) {
if (cur == head) {
cur = cur.next;
}
else {
cur = cur.next;
prev = prev.next;
}

if (cur == null) {
return null;
}
}

ListNode newHead = cur;
ListNode newPrev = newHead;
if (newHead == head)
flag = true;


while (diff-- > 0 ){
if (cur == null)
return null;
if (cur == newHead) {
cur = cur.next;
if (cur == null)
return null;
}
newPrev.next = cur.next;
cur.next = newHead;
newHead = cur;
cur = newPrev.next;
}


if (flag == false){
prev.next = newHead;
return head;
}
else
return newHead;
}
avatar
l*7
24
这个网站也够搞笑的,所有的包MARKET PRICE都是259刀~
avatar
A*i
25
这做法我觉得很好
很多情况下list里面的data都存的不过是个索引而已,C/C++下面存对象(数据)的地址
,java下存的是reference,就算真存的是int或者单一的数据也很简单,根本没有必要
来操作那个next指针
但是面试官能不能过就另一回事

nodes

【在 r*********n 的大作中提到】
: i know this is cheating, but can't you just swap the values of the two nodes
: ?

avatar
x*o
26
貌似可以查是哪里的人开的= =以前见过谁查过...
avatar
A*g
27
链表没有random access,swap value的话要jump back and forth, 复杂度大概是O(N
^2)。 recursion的话等于把每个节点的地址都存到stack里,所以时间是O(N),空间也
是O(N)。 话说回来,如果先用一个array把每个链表节点的地址存起来,那么既可以反
转next,也可以swap value, 都是O(N),和recursion一样了,code也挺好写。
谢谢你给的灵感! 对这题的认识又加深了。

nodes

【在 r*********n 的大作中提到】
: i know this is cheating, but can't you just swap the values of the two nodes
: ?

avatar
w*r
28
这些都是公共信息,到这里查一下就知道了
http://www.register.com/whois.rcmx

【在 x****o 的大作中提到】
: 貌似可以查是哪里的人开的= =以前见过谁查过...
avatar
c*t
29
Think again

(N
★ 发自iPhone App: ChineseWeb 7.8

【在 A******g 的大作中提到】
: 链表没有random access,swap value的话要jump back and forth, 复杂度大概是O(N
: ^2)。 recursion的话等于把每个节点的地址都存到stack里,所以时间是O(N),空间也
: 是O(N)。 话说回来,如果先用一个array把每个链表节点的地址存起来,那么既可以反
: 转next,也可以swap value, 都是O(N),和recursion一样了,code也挺好写。
: 谢谢你给的灵感! 对这题的认识又加深了。
:
: nodes

avatar
f*y
30
福建莆田注册的网站。。。
avatar
c*g
31
牛人很多,居然找到福建莆田注册的。
懂了。
谢谢各位指点
avatar
c*g
32
刚来美国,不好意思。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。