Skip to content

Commit

Permalink
feat: solved raig
Browse files Browse the repository at this point in the history
  • Loading branch information
boianradu committed Jun 27, 2023
1 parent cee6ca0 commit dfd4936
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions reverse_array_in_groups/raig.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
#User function template for Python

global arr
class Solution:
#Function to reverse every sub-array group of size k.
def reverseInGroups(self, arr, N, K):
print("ana are mere")
for x in arr:
print(x)
# code here
def chunker(self, seq, size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
def reverseInGroups(self, arr, N, K):
newArr=[]
for x in self.chunker(list(arr),K):
for i, e in reversed(list(enumerate(x))):
newArr.append(e)
print(e,end=" ")
print()
arr=set(newArr)
return arr


import math
def main():
N = 5
K = 3
arr = {1,2,3,4,5}
ob = Solution()
ob.reverseInGroups(arr,N,K)
for i in arr:
print(i,end=" ")
print()

if __name__=="__main__":
main()



0 comments on commit dfd4936

Please sign in to comment.