Skip to content

Instantly share code, notes, and snippets.

View prasadwrites's full-sized avatar

Prasad prasadwrites

View GitHub Profile
#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){
#! /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=[]
#include <iostream>
#include <vector>
using namespace std;
class StringNum {
public:
vector<string> result;
string bag;
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
@prasadwrites
prasadwrites / Combinations.py
Last active June 30, 2023 14:46
Combinations of strings
#! /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:])
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:
@prasadwrites
prasadwrites / letterPermutationSort.py
Created April 14, 2021 22:30
a1b2 => ['A1B2', 'A1b2', 'a1B2', 'a1b2']
#! /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)
@prasadwrites
prasadwrites / selection.py
Created March 28, 2021 05:02
selection sort
#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]
@prasadwrites
prasadwrites / generate_image.py
Created December 7, 2020 13:07
generater image
#!/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 = []
@prasadwrites
prasadwrites / concat.py
Created December 7, 2020 13:06
concat.py
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')):