This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| #include<vector> | |
| using namespace std; | |
| vector<int> bag = { 2, 8, -2 }; | |
| int sum = 6, index=0; | |
| int bagSize; | |
| bool flag = false; | |
| bool printSubsetSums(int index , vector<int> slate){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/env/path python | |
| ''' This solution is done using list and removes the immutable | |
| string to avoid extra burden on time ''' | |
| def solutions(): | |
| result=[] | |
| def helper(index,slate=None): | |
| if slate== None: | |
| slate=[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| class StringNum { | |
| public: | |
| vector<string> result; | |
| string bag; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| arr = ['G','B','R','G','B','G','R'] | |
| ridx=0 | |
| bidx=len(arr)-1 | |
| i=0 | |
| while(i<bidx): | |
| if(arr[i] == 'R'): | |
| arr[i],arr[ridx] = arr[ridx],arr[i] | |
| ridx += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/env/path python | |
| def printCombinations(slate,array): | |
| if (len(array)==0): | |
| print(slate) | |
| return | |
| printCombinations(slate,array[1:]) | |
| printCombinations(slate+array[0], array[1:]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import deque | |
| # 1->2->3->4->4->3->2->1 | |
| # b b b b | |
| # f f f b | |
| # 1->2->3->4->5->4->3->2->1 | |
| # b b b b b | |
| # f f f f f | |
| # Definition for singly-linked list. | |
| # class ListNode: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/env/path python | |
| def helper(string, result, index , slate): | |
| if (len(string) == len(slate)): | |
| result.append(slate) | |
| return | |
| if(string[index].isdigit()): | |
| slate = slate + str(string[index]) | |
| helper(string, result, index+1, slate) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #usr/bin/env python | |
| arr = [1,3,6,7,4,6,8,9,1,4,6,7] | |
| for i in range(len(arr)): | |
| for j in range(i,len(arr)): | |
| if arr[j] < arr[i]: | |
| temp = arr[j] | |
| arr[j] = arr[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| from PIL import Image | |
| # Open background and foreground and ensure they are RGB (not palette) | |
| list_of_files_bg = [] | |
| list_of_files_fg = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import os | |
| from moviepy.editor import VideoFileClip, concatenate_videoclips,CompositeVideoClip | |
| from PIL import Image | |
| list_of_candidates = [] | |
| for (dirpath, dirnames, filenames) in os.walk("."): | |
| for filename in filenames: | |
| if (filename.endswith('.png') or filename.endswith('.jpg')): |