From b16b7c09d3218fd67f5570add7a880c29421305b Mon Sep 17 00:00:00 2001 From: ussamaawan <91910265+ussamaawan@users.noreply.github.com> Date: Sun, 18 Sep 2022 21:28:58 +0500 Subject: [PATCH] Update and rename solution.py to Question 2 solution.py --- Q2/Question 2 solution.py | 17 +++++++++++++++++ Q2/solution.py | 8 -------- 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 Q2/Question 2 solution.py delete mode 100644 Q2/solution.py diff --git a/Q2/Question 2 solution.py b/Q2/Question 2 solution.py new file mode 100644 index 0000000..f2d0507 --- /dev/null +++ b/Q2/Question 2 solution.py @@ -0,0 +1,17 @@ +#first we need to find the size for that we are introducing a function +def len_link(list): + temp=list.head + count=0 + while(temp): + count+=1 + temp=temp.next + return count + # then from that size value we will use for calculating head + size = len .link(optional) + temp= size-n + # using for loop + for i in range (0,size): + if i == temp: + optional .remove(i) + return optional.head + diff --git a/Q2/solution.py b/Q2/solution.py deleted file mode 100644 index dd114fb..0000000 --- a/Q2/solution.py +++ /dev/null @@ -1,8 +0,0 @@ -# Definition for singly-linked list. -# class ListNode: -# def __init__(self, val=0, next=None): -# self.val = val -# self.next = next -class Solution: - def removeNthFromEnd(self, head: Optional[ListNode], n: int) -> Optional[ListNode]: -