Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc1bf342

Browse files
refactor 234
1 parente85cbb5 commitc1bf342

File tree

1 file changed

+6
-13
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+6
-13
lines changed

‎src/main/java/com/fishercoder/solutions/_234.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@
55
importjava.util.ArrayList;
66
importjava.util.List;
77

8-
/**
9-
* 234. Palindrome Linked List
10-
*
11-
* Given a singly linked list, determine if it is a palindrome.
12-
13-
Follow up:
14-
Could you do it in O(n) time and O(1) space?
15-
*/
16-
178
publicclass_234 {
189
publicstaticclassSolution1 {
19-
/**O(n) time
10+
/**
11+
* O(n) time
2012
* O(1) space
21-
* */
13+
*/
2214
publicbooleanisPalindrome(ListNodehead) {
2315
if (head ==null) {
2416
returntrue;
@@ -56,9 +48,10 @@ private ListNode reverse(ListNode head) {
5648
}
5749

5850
publicstaticclassSolution2 {
59-
/**O(n) time
51+
/**
52+
* O(n) time
6053
* O(n) space
61-
* */
54+
*/
6255
publicbooleanisPalindrome(ListNodehead) {
6356
intlen =0;
6457
ListNodefast =head;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp