@@ -154,6 +154,43 @@ class Solution {
154154}
155155```
156156
157+ ``` csharp
158+ /**
159+ * Definition for singly-linked list.
160+ * public class ListNode {
161+ * public int val;
162+ * public ListNode next;
163+ * public ListNode(int val=0, ListNode next=null) {
164+ * this.val = val;
165+ * this.next = next;
166+ * }
167+ * }
168+ */
169+
170+ public class Solution {
171+ public int PairSum (ListNode head ) {
172+ List < int > arr = new List <int >();
173+ ListNode cur = head ;
174+
175+ while (cur != null ) {
176+ arr .Add (cur .val );
177+ cur = cur .next ;
178+ }
179+
180+ int i = 0 , j = arr .Count - 1 ;
181+ int res = 0 ;
182+
183+ while (i < j ) {
184+ res = Math .Max (res , arr [i ] + arr [j ]);
185+ i ++ ;
186+ j -- ;
187+ }
188+
189+ return res ;
190+ }
191+ }
192+ ```
193+
157194``` go
158195/* *
159196 * Definition for singly-linked list.
@@ -466,6 +503,50 @@ class Solution {
466503}
467504```
468505
506+ ``` csharp
507+ /**
508+ * Definition for singly-linked list.
509+ * public class ListNode {
510+ * public int val;
511+ * public ListNode next;
512+ * public ListNode(int val=0, ListNode next=null) {
513+ * this.val = val;
514+ * this.next = next;
515+ * }
516+ * }
517+ */
518+
519+ public class Solution {
520+ public int PairSum (ListNode head ) {
521+ ListNode slow = head , fast = head ;
522+
523+ while (fast != null && fast .next != null ) {
524+ slow = slow .next ;
525+ fast = fast .next .next ;
526+ }
527+
528+ ListNode prev = null , cur = slow ;
529+ while (cur != null ) {
530+ ListNode nxt = cur .next ;
531+ cur .next = prev ;
532+ prev = cur ;
533+ cur = nxt ;
534+ }
535+
536+ int res = 0 ;
537+ ListNode first = head , second = prev ;
538+
539+ while (second != null ) {
540+ res = Math .Max (res , first .val + second .val );
541+ first = first .next ;
542+ second = second .next ;
543+ }
544+
545+ return res ;
546+ }
547+ }
548+ ```
549+
469550``` go
470551/* *
471552 * Definition for singly-linked list.
@@ -782,6 +863,45 @@ class Solution {
782863}
783864```
784865
866+ ``` csharp
867+ /**
868+ * Definition for singly-linked list.
869+ * public class ListNode {
870+ * public int val;
871+ * public ListNode next;
872+ * public ListNode(int val=0, ListNode next=null) {
873+ * this.val = val;
874+ * this.next = next;
875+ * }
876+ * }
877+ */
878+
879+ public class Solution {
880+ public int PairSum (ListNode head ) {
881+ ListNode slow = head , fast = head ;
882+ ListNode prev = null ;
883+
884+ while (fast != null && fast .next != null ) {
885+ fast = fast .next .next ;
886+ ListNode tmp = slow .next ;
887+ slow .next = prev ;
888+ prev = slow ;
889+ slow = tmp ;
890+ }
891+
892+ int res = 0 ;
893+
894+ while (slow != null ) {
895+ res = Math .Max (res , prev .val + slow .val );
896+ prev = prev .next ;
897+ slow = slow .next ;
898+ }
899+
900+ return res ;
901+ }
902+ }
903+ ```
904+
785905``` go
786906/* *
787907 * Definition for singly-linked list.
0 commit comments