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 Trie: | |
| def __init__(self): | |
| """ | |
| Initialize your data structure here. | |
| """ | |
| self.root_dict = {} | |
| def insert(self, word): | |
| """ |
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 Backend(object): | |
| """Allows access to backend and removes logic from handlers""" | |
| def __init__(self): | |
| """Inititalize with the variables you need""" | |
| self.__users_data = None | |
| self.db = Connection( | |
| options.db_host, | |
| options.db, | |
| user=options.db_user, |
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
| on run argv | |
| set targetTabName to quoted form of (item 1 of argv) | |
| set targetFullPath to (item 2 of argv) | |
| tell application "Safari" | |
| --Variables | |
| set targetWindow to 0 | |
| set targetTab to 0 | |
| set found to false | |
| --Repeat for Every Window |
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
| on run argv | |
| set targetTabName to quoted form of (item 1 of argv) | |
| set targetFullPath to (item 2 of argv) | |
| tell application "Google Chrome" | |
| --Variables | |
| set targetWindow to 0 | |
| set found to false | |
| set targetTab to 0 | |
| --Repeat for Every Window | |
| repeat with theWindow in every window |
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
| dependencies { | |
| compile project(':foo'), project(':bar') | |
| } |
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
| sgupta-mbp:~ sgupta$ cpan -l |grep LocalEnv | |
| Can't stat /Network/Library/Perl/5.18/darwin-thread-multi-2level: No such file or directory | |
| at /System/Library/Perl/5.18/App/Cpan.pm line 1216. | |
| Can't stat /Network/Library/Perl/5.18: No such file or directory | |
| at /System/Library/Perl/5.18/App/Cpan.pm line 1216. | |
| App::PerlLocalEnv undef | |
| Can't cd to (/Users/sgupta/.cpan/build/Module-Install-1.16-tf5h8B/) lib: Permission denied | |
| at /System/Library/Perl/5.18/App/Cpan.pm line 1216. | |
| Can't cd to (/Users/sgupta/.cpan/build/Module-Install-1.16-tf5h8B/) t: Permission denied | |
| at /System/Library/Perl/5.18/App/Cpan.pm line 1216. |
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
| too_large = 1e12 | |
| def violations(words, page_width): | |
| """ | |
| The greater this is the worst the worst is the violation. | |
| TODO(Sid): abs?? | |
| """ | |
| cost = page_width - (sum(len(i) for i in words) + len(words) - 1) | |
| if cost < 0: | |
| return too_large | |
| else: |
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
| {0.0007331374358727771, | |
| 0.0019193787255176176, | |
| 0.002652516161447238, | |
| 0.003838757451035235, | |
| 0.0050249987406445484, | |
| 0.005758136176552853, | |
| 0.006944377466169271, | |
| 0.00767751490207047, | |
| 0.008863756191658467, | |
| 0.010049997481289097, |
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
| # This is a proposed implementation of single source shortest path using DFS | |
| class FailBowlDFS(object): | |
| no_path_to_dest = 1e10 # more than any node | |
| def __init__(self, tree, cost): | |
| self.cost = cost | |
| self.tree = tree | |
| self.min_dist = {} | |
| self.visited = set() |
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: | |
| # @param root, a tree node | |
| # @return a list of lists of integers | |
| def levelOrder(self, root): | |
| self.level_order_list = [] | |
| self.dfs_traverse(root, l = 0) | |
| return self.level_order_list |