Skip to content

Instantly share code, notes, and snippets.

View shubham1710's full-sized avatar
🎯
Focusing

Kumar Shubham shubham1710

🎯
Focusing
View GitHub Profile
@shubham1710
shubham1710 / Conv.py
Created December 11, 2019 05:30
Word to html
import subprocess
import os
import uuid
def document_to_html(file_path):
tmp = "/tmp"
guid = str(uuid.uuid1())
# convert the file, using a temporary file w/ a random name
command = "abiword -t %(tmp)s/%(guid)s.html %(file_path)s; cat %(tmp)s/%(guid)s.html" % locals()
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=os.path.join(settings.PROJECT_DIR, "website/templates"))
@shubham1710
shubham1710 / Merge.cpp
Created December 11, 2019 11:55
Merging intervals
#include<bits/stdc++.h>
using namespace std;
// An Interval
struct Interval
{
@shubham1710
shubham1710 / Dd.cpp
Created December 12, 2019 12:20
Tyhh
#include<bits/stdc++.h>
using namespace std;
int maxSum(int arr[], int n)
{
// Compute sum of all array elements
int cum_sum = 0;
for (int i=0; i<n; i++)
cum_sum += arr[i];
// Compute sum of i*arr[i] for initial
// configuration.
int main() {
int n, k; cin >> n >> k;
vector<int> v(n);
for(int i = 0; i < n; ++i)
cin >> v[i];
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
int tot = 0;
for(int i = 0; i < n; ++i) {
#include <iostream>
using namespace std;
// A Binary Tree Node
struct Node
{
struct Node *left, *right;
int key;
};
// Utility function to create a new tree Node
Node* newNode(int key)
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostrea
#include <algorithm>
using namespace std;
int repeatedNumber( vector<int> &A) {
int n = A.size();
if(n == 0) return -1;
if(n <= 2) return A[0];
import math
from collections import Counter
a=input()
k=Counter(list(a)).most_common()
u=list(int(x[1]) for x in k)
u=sorted(u)
m_num=Counter(u).most_common()
class Solution {
public:
vector<int> maxset(vector<int> Vec) {
int N = Vec.size();
long long mx_sum = 0;
long long cur_sum = 0;
int mx_range_left = -1;
int mx_range_right = -1;
@shubham1710
shubham1710 / Ffm.cpp
Created December 20, 2019 13:20
Ghtw
class Solution {
public:
int lis(const vector<int> &V) {
if (V.size() == 0) return 0;
int longest[V.size() + 1];
int maxLen = 1;
memset(longest, 0, sizeof(longest));
// longest[i] denotes the maximum length of increasing subsequence that ends
// with V[i].
longest[0] = 1;
@shubham1710
shubham1710 / Ghpc.cpp
Created December 21, 2019 13:31
Ddsszz
bool isAsterisk(char c){
return c == '*';
}
bool isQuestion(char c){
return c == '?';
}
bool isMatchSymbol(char s, char m){
return isQuestion(m) || s == m;
}
int Solution::isMatch(const string source, const string mask) {