From 17114d2977d77637f6785004e21f8fc9dd71a3f0 Mon Sep 17 00:00:00 2001 From: Dipankar Anand Date: Thu, 24 Oct 2019 02:00:46 +0530 Subject: [PATCH] Create starting_indices_of_anagrams.py --- .../Python/starting_indices_of_anagrams.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Company Specific Interview Questions/Google/Solutions/Python/starting_indices_of_anagrams.py diff --git a/Company Specific Interview Questions/Google/Solutions/Python/starting_indices_of_anagrams.py b/Company Specific Interview Questions/Google/Solutions/Python/starting_indices_of_anagrams.py new file mode 100644 index 00000000..8320b4b6 --- /dev/null +++ b/Company Specific Interview Questions/Google/Solutions/Python/starting_indices_of_anagrams.py @@ -0,0 +1,33 @@ +W = raw_input("Enter any word to search : ") +S = raw_input("Enter any string : ") + +w = [] +s = [] +a = [] +s1 = [] + +for i in W: + w.append(i) +for i in S: + s.append(i) + +n = len(w) +m = len(s) +w.sort() + +if m >= n: + for i in range(0,n): + s1.append(s[i]) + if s1 == w: + print(0) + for i in range(1,m-n+1): + s2 = [] + del s1[0] + s1.append(s[i+n-1]) + for j in s1: + s2.append(j) + s2.sort() + if(s2 == w): + print(i) +else: + print("Word is bigger than string")