Given a string S of length N, find the pattern of the strings as shown below in the examples.
Example 1:
Input: S = "GeeK"
Output: Geek
        Gee
        Ge
        G
Explanation: Decrease one character 
after each line
Ã¢â¬â¹Example 2:
Input: S = "G*g" 
Output: G*g
        G*
        G
Explanation: Decrease one character
after each line
Your Task:  
You don't need to read input or print anything. Your task is to complete the function pattern() which takes the string S as inputs and returns the answer as a list of strings.
Expected Time Complexity: O(N^{2})
Expected Auxiliary Space: O(N^{2})
Constraints:
1 ≤ N ≤ 10^{3}

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3
class Solution:
	def pattern(self, S):
		# code here

Solutions:
class Solution:

	def pattern(self, S):
		l = []
		for i in range(len(S), 0, -1):
			l.append(S[:i])
		return l


class Solution:

	def pattern(self, S):
		ans = []
		n = len(S)
		for i in range(n):
			ans.append(S[:n - i])
		return ans


class Solution:

	def pattern(self, S):
		res = []
		max_val = len(S)
		for e in S:
			res.append(S[0:max_val])
			max_val = max_val - 1
		return res


class Solution:

	def pattern(self, s):
		length = len(s)
		res = []
		for i in range(length):
			res.append(s[:length - i])
		return res


class Solution:

	def pattern(self, S):
		result = []
		for i in range(len(S), 0, -1):
			line = S[:i]
			result.append(line)
		return result


class Solution:

	def pattern(self, S):
		a = []
		c = len(S)
		if c == 1:
			return S
		else:
			for i in range(c):
				a.append(S[0:c - i])
			return a


class Solution:

	def pattern(self, S):
		result = []
		a = list(str(S))
		i = len(S) - 1
		while i >= 0:
			result.append(''.join(a))
			a.pop(i)
			i -= 1
		return result


class Solution:

	def pattern(self, S):
		a = []
		for i in range(len(S)):
			a.append(S[:len(S) - i])
		return a


class Solution:

	def pattern(self, S):
		subStr = []
		for st in range(len(S), 0, -1):
			subStr.append(S[:st])
		return subStr


class Solution:

	def pattern(self, S):
		k = len(S)
		l = []
		v = ''
		for i in range(0, len(S)):
			for j in range(0, k):
				v += S[j]
			k -= 1
			l.append(v)
			v = ''
		return l


class Solution:

	def pattern(self, S):
		n = len(S)
		A = []
		for i in range(n, 0, -1):
			A.append(S[0:i])
		return A


class Solution:

	def pattern(self, S):
		result = []
		i = 0
		n = len(S)
		for i in range(n):
			result.append(S[0:n - i])
		return result


class Solution:

	def pattern(self, S):
		strin = list(S)
		result = [S]
		while len(strin) != 1:
			strin.pop()
			result.append(''.join(strin))
		return result


class Solution:

	def pattern(self, S):
		list1 = []
		for i in range(len(S)):
			if i == 0:
				list1.append(S)
			else:
				list1.append(S[:-i])
		return list1


class Solution:

	def pattern(self, S):
		start = 0
		end = len(S) - 1
		ans = []
		for _ in range(len(S)):
			ans.append(S[start:end + 1])
			end -= 1
		return ans


class Solution:

	def pattern(self, S):
		N = len(S)
		A = [S[:N - I] for I in range(N)]
		return A


class Solution:

	def pattern(self, S):
		i = len(S)
		ans = []
		while i >= 1:
			ans.append(S[:i])
			i -= 1
		return ans


class Solution:

	def pattern(self, S):
		l = []
		for i in range(len(S)):
			x = S[:len(S) - i]
			l.append(x)
		return l


class Solution:

	def pattern(self, S):
		a = []
		S = list(S)
		for i in range(len(S)):
			a.append(''.join(S))
			S.pop()
		return a


class Solution:

	def pattern(self, S):
		l = len(S)


class Solution:

	def pattern(self, S):
		x = []
		for i in range(len(S), 0, -1):
			a = S[0:i]
			x.append(a)
		return x


class Solution:

	def pattern(self, S):
		l = len(S)
		for i in range(l):
			add = ''
			for j in range(0, l - i):
				add = add + S[j]
			yield add


class Solution:

	def pattern(self, s):
		res = []
		for i in range(len(s), 0, -1):
			temp = s[:i]
			res.append(temp)
		return res


class Solution:

	def pattern(self, S):
		l1 = []
		for i in range(0, len(S)):
			l1.append(S[0:len(S) - i])
		return l1


class Solution:

	def pattern(self, S):
		n = len(S)
		t = []
		for i in range(len(S)):
			if i == 0:
				t.append(S)
			else:
				t.append(S[:-i])
		return t


class Solution:

	def pattern(self, str):
		list = []
		for i in range(len(str)):
			list.append(str[:len(str) - i])
		return list


class Solution:

	def substring(self, S, start, end):
		temp = ''
		for i in range(start, end):
			temp += S[i]
		return temp

	def pattern(self, S):
		patt = []
		for i in range(len(S), 0, -1):
			patt.append(self.substring(S, 0, i))
		return patt


class Solution:

	def pattern(self, S):
		output = []
		l = len(S)
		for i in S:
			output.append(S[:l])
			l -= 1
		return output


class Solution:

	def pattern(self, S, li=[]):
		for i in range(1, len(S) + 1):
			li = [S[:i]] + li
		return li


class Solution:

	def pattern(self, S):
		k = 0
		l = []
		while k < len(S):
			l.append(S[0:len(S) - k])
			k += 1
		return l


class Solution:

	def pattern(self, S):
		i = len(S)
		new_string = ''
		while i != 0:
			new_string += S[0:i]
			i -= 1
			if len(S) != 0:
				print(new_string)
			new_string = ''
		return new_string


class Solution:

	def pattern(self, s):
		n = len(s)
		l = []
		for i in range(n, 0, -1):
			l.append(s[:i])
		return l


class Solution:

	def pattern(self, S):
		k = []
		k[:] = S
		l = []
		for i in range(len(k)):
			p = []
			for j in range(i + 1):
				p.append(k[j])
			m = ''.join(p)
			l.append(m)
		n = l[::-1]
		return n


class Solution:

	def pattern(self, S):
		li = []
		o = len(S)
		for i in S:
			li.append(S[:o])
			o = o - 1
		return li


class Solution:

	def pattern(self, S):
		l = len(S)
		for i in range(l):
			yield S[:l]
			l -= 1


class Solution:

	def pattern(self, S):
		str = ''
		lst = []
		for i in range(len(S)):
			for j in range(len(S) - i):
				str += S[j]
			lst.append(str)
			str = ''
		return lst


class Solution:

	def pattern(self, S):
		self.S = S
		ans = []
		for i in range(len(S), 0, -1):
			a = ''
			for j in range(i):
				a += S[j]
			ans.append(a)
		return ans


class Solution:

	def pattern(self, S):
		(out, lis) = ([], [])
		for i in S:
			lis.append(i)
		while lis:
			temp = ''
			for i in lis:
				temp += i
			out.append(temp)
			lis = lis[:-1]
		return out


class Solution:

	def pattern(self, s):
		l = []
		n = len(s)
		while n != 0:
			l.append(s[:n])
			n -= 1
		return l