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 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")) |
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<bits/stdc++.h> | |
using namespace std; | |
// An Interval | |
struct Interval | |
{ |
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<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. |
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
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) { |
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> | |
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) |
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 <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]; |
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 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() |
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
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; |
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
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; |
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
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) { |
OlderNewer