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 findCircleNum(self, isConnected: List[List[int]]) -> int: | |
| count = 0 | |
| length = len(isConnected) | |
| for i in range(length): | |
| if isConnected[i][i] == 1: | |
| count += 1 | |
| self.dfs(i, length, isConnected) | |
| return count |
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
| def river_sizes(matrix): | |
| sizes = [] | |
| visited = [[False for value in row] for row in matrix] | |
| for i in range(len(matrix)): | |
| for j in range(len(matrix[i])): | |
| if visited[i][j]: | |
| continue | |
| traverse_node(i, j, matrix, visited, sizes) | |
| return sizes |
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 sys | |
| import csv | |
| semicolonin = csv.reader(sys.stdin, delimiter=';') | |
| commaout = csv.writer(sys.stdout, delimiter=',') | |
| for row in semicolonin: | |
| commaout.writerow(row) |
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
| var mongo = require('mongodb'); | |
| var Inserter = function (collection) { | |
| this.collection = collection; | |
| this.data = []; | |
| this.maxThreads = 6; | |
| this.currentThreads = 0; | |
| this.batchSize = 5000; | |
| this.queue = 0; | |
| this.inserted = 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
| function toTitleCase(str) { | |
| return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); | |
| } |
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
| db.zips.find({city : { $regex : /^[0-9]/ }}) |
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
| mongoimport --db pcat --collection products < products.json |
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
| var mention_id = 620996; | |
| db.mentionStats.aggregate([ | |
| { $match: {'mention_id': mention_id}}, | |
| { $group: {'_id': { | |
| 'year': { '$year': "$verification_date" }, | |
| 'month': { '$month': "$verification_date" }, | |
| 'day': { '$dayOfMonth': "$verification_date" } | |
| }, | |
| 'retweets': { $last: "$retweets" }}}, |
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
| var start = new Date(2013, 5, 4) | |
| var end = new Date(2013, 5, 6) | |
| db.mention_stat.find({"verification": {"$gte": start, "$lt": 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
| db.link_access.group( | |
| { | |
| keyf: function(doc) { | |
| var date = new Date(doc.date); | |
| var dateKey = (date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear()+''; | |
| return {'day': dateKey}; | |
| }, | |
| cond: {short_id: "N"}, | |
| initial: {count:0}, | |
| reduce: function(obj, prev) {prev.count++;} |
NewerOlder