Skip to content

Instantly share code, notes, and snippets.

View iHaikal's full-sized avatar
🎯
Focusing

Hesham Haikal iHaikal

🎯
Focusing
View GitHub Profile
@iHaikal
iHaikal / twoSums.java
Created May 28, 2019 01:57
a submitted solution to TwoSums problem in Leetcode
// problem: https://leetcode.com/problems/two-sum/
import java.util.HashMap;
class Solution {
int[] twoSum(int[] nums, int target){
int firstIndex = -1, secondIndex = -1;
HashMap<Integer, Integer> map = new HashMap<>();
@iHaikal
iHaikal / rem_comp_suff.py
Created October 12, 2021 17:38
Remove company suffixes
names = ['Atlantia SpA', 'Amazon.com', 'Banco Bilbao Vizcaya Argentaria SA', 'Carl Zeiss Meditec AG', 'Antofagasta PLC', 'Bunzl plc', 'SK Hynix Inc', 'Hang Seng Bank Ltd', 'Salesforce.Com', 'Kia Motors Corp', 'Zurich Insurance Group AG']
suffices = ['Inc', 'LTD', 'SA', 'AG', '.com', 'Corp', 'Group', 'SPA', 'PLC']
[w[:-len(s)] for w in names for s in suffices if w.lower().endswith(s.lower())]
@iHaikal
iHaikal / dot.py
Created October 12, 2021 17:40
Regular JSON to dotted
import json
with open('test_dictionary_regular.json') as f:
data = json.load(f)
with open('test_dictionary_dot.json') as f:
test = json.load(f)
def to_dot(data: dict) -> dict:
out = {}