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: | |
| def hasAllCodes(self, s: str, k: int) -> bool: | |
| num_perms = math.pow(2, k) | |
| substrings_of_len_k = len(s) - k + 1 | |
| if substrings_of_len_k < num_perms: | |
| return False | |
| perms = set() | |
| for i in range(k, len(s)+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
| #!/bin/bash | |
| # convert the saves of Remedy's Control game from Epic's format to GOG's | |
| DEST=$(pwd) | |
| if [ $# != "1" ] || ! [ -d "$1" ]; then | |
| echo "A directory must be provided" | |
| exit 1 | |
| fi |
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
| # Pause process until a key is pressed | |
| kill -STOP $PID; sh -c "read -n 1 -s -r -p 'Press any key to continue'"; kill -CONT $PID |
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
| // https://leetcode.com/problems/merge-sorted-array/ | |
| class Solution | |
| { | |
| public: | |
| void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) | |
| { | |
| int writeIdx = m + n - 1; | |
| int r1 = m - 1; | |
| int r2 = n - 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
| // https://leetcode.com/problems/triangle/ | |
| class Solution | |
| { | |
| public: | |
| int minimumTotal(vector<vector<int> > &triangle) | |
| { | |
| if (triangle.size() == 1) | |
| return triangle[0][0]; | |
| for (int i = triangle.size() - 1 - 1; i >= 0; 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
| class Solution | |
| { | |
| int internal(const vector<int>& nums, int start, int end) | |
| { | |
| if (nums.size() == 1) | |
| return nums[0]; | |
| if (end - start == 1) | |
| return min(nums[start], nums[end]); | |
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
| template <typename T> | |
| string join(const vector<T> &v, const string &sep) | |
| { | |
| ostringstream oss; | |
| for (const T &element: v) | |
| oss << element << sep; | |
| const string out = oss.str(); |
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
| #!/bin/sh | |
| wajig install -y tidy ppa-purge htmldoc dirdiff nmap audacity lm-sensors buffer parallel filelight htop testdisk woof realpath traceroute meld pavumeter p7zip-full | |
| wajig install -y chmsee ipython qtcreator mercurial git idle filezilla chromium-browser krfb rakarrack sox samba zim exuberant-ctags xchat yakuake | |
| wajig install -y pandoc optipng libboost-filesystem binutils-dev gdc scons python-beautifulsoup python-ipdb ssh screen | |
| wajig install -y yudit nemiver kdbg python-pip python-virtualenv skype fmit uget vlc cheese gimp mplayer2 conky gparted colordiff dot graphviz scite pavucontrol tuxguitar | |
| wajig install -y apt-file ack-grep cccc dos2unix powertop | |
| wajig install -y jedit iotop git-gui gitk parted synergy krusader shutter guvcview | |
| wajig install -y synaptic playonlinux ttf-mscorefonts-installer build-essential g++ winff pinta avinfo subversion hardinfo kubuntu-restricted-extras kubuntu-restricted-addons | |
| wajig install -y pitivi smplayer vim-gtk libreoffice keepassx bleachbit handbrake httrack web |