This file contains 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
# Definition for singly-linked list. | |
# class ListNode(object): | |
# def __init__(self, x): | |
# self.val = x | |
# self.next = None | |
class Solution(object): | |
def addTwoNumbers(self, l1, l2): | |
""" | |
:type l1: ListNode |
This file contains 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: | |
def twoSum(self, nums, target): | |
""" | |
:type nums: List[int] | |
:type target: int | |
:rtype: List[int] | |
""" | |
dict = {} | |
for i in range(len(nums)): | |
complement = target - nums[i] |
This file contains 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
def create(self, cr, uid, vals, context=None, check=True): | |
# Calculate the acutal_fee and discounts again as readonly fields aren't | |
# stored in the database. | |
std_id = vals.get('student_id') | |
res = self.onchange_get_actual_fee(cr, uid, std_id, std_id, vals.get('fee_type'), context) | |
acutal_fee = res.get('value').get('actual_fee') | |
discounted_fee = acutal_fee - (vals.get('discount') * acutal_fee/100) | |
vals.update({'actual_fee':acutal_fee}) |
This file contains 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
Verifying that "aadimator.id" is my Blockstack ID. https://onename.com/aadimator |
This file contains 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; | |
int main() { | |
int t, a, output = 0; | |
cin >> t; | |
while(t--){ | |
cin >> a; | |
output += a; | |
} |
This file contains 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 <string> | |
using namespace std; | |
int main(){ | |
int n; | |
cin >> n; | |
This file contains 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; | |
int main(){ | |
int t; | |
cin >> t; | |
for(int a0 = 0; a0 < t; a0++){ | |
int n; | |
cin >> n; |
This file contains 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 std::vector; | |
vector<int> optimal_summands(int n) { | |
// using the algorithm described in the pdf | |
vector<int> summands; | |
for (int k = n, l = 1; k > 0; l++) { | |
if (k <= 2 * l) { |
This file contains 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 <algorithm> | |
#include <iostream> | |
using std::vector; | |
struct Segment { | |
int start, end; | |
}; | |
vector<int> optimal_points(vector<Segment> &segments) { |
This file contains 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 <algorithm> | |
#include <iostream> | |
using std::vector; | |
long long min_dot_product(vector<int> a, vector<int> b) { | |
std::sort(a.begin(), a.end()); | |
std::sort(b.begin(), b.end(), std::greater<int>()); | |
long long result = 0; | |
for (int i = 0; i < a.size(); i++) { |