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 has_cycle(head): | |
| if head is None: | |
| return False | |
| begin = end = head | |
| while (begin or end or end.next): | |
| if end.next is None: | |
| return False |
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
| """ Node is defined as | |
| class node: | |
| def __init__(self, data): | |
| self.data = data | |
| self.left = None | |
| self.right = None | |
| """ | |
| def isBSTUtil(node, min, max): | |
| if node.data <= min: |
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 minSwaps(arr) { | |
| //using selection sort O(N^2) | |
| let n = arr.length; | |
| let initial_min_no = 0, | |
| initial_min_index = 0, | |
| swaps = 0; | |
| for (let i = 0; i < n - 1; 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
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| <meta name="exporter-version" content="Evernote Mac 6.13.3 (455969)" /> | |
| <meta name="altitude" content="331.4588012695312" /> | |
| <meta name="author" content="[email protected]" /> | |
| <meta name="created" content="2018-02-22 13:17:51 +0000" /> | |
| <meta name="latitude" content="30.71890173873824" /> | |
| <meta name="longitude" content="76.8103098519497" /> |
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
| for i in range(int(input())): #More than 4 lines will result in 0 score. Blank lines won't be counted. | |
| a = int(input()); A = set(input().split()) | |
| b = int(input()); B = set(input().split()) | |
| print(A.issubset(B)) |
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
| from itertools import groupby | |
| K = int(input()) | |
| lis = list(map(int, input().split())) | |
| dic = {} | |
| min=0 | |
| for i in lis: | |
| if str(i) not in dic: | |
| dic[str(i)] = 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
| length=int(input()) | |
| s=set(map(int, input().split())) | |
| N=int(input()) | |
| for i in range(N): | |
| (p, q)=input().split() | |
| s2=set(map(int, input().split())) | |
| if p=='intersection_update': | |
| s.intersection_update(s2) | |
| elif p=='update': |
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
| n = int(input()) | |
| enp = set(map(int, input().split())) | |
| b = int(input()) | |
| fnp = set(map(int, input().split())) | |
| c = enp.symmetric_difference(fnp) | |
| print(len(c)) |
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
| n = int(input()) | |
| enp = set(map(int, input().split())) | |
| b = int(input()) | |
| fnp = set(map(int, input().split())) | |
| c = enp.difference(fnp) | |
| print(len(c)) |
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
| n = int(input()) | |
| enp = set(map(int, input().split())) | |
| b = int(input()) | |
| fnp = set(map(int, input().split())) | |
| c = enp.intersection(fnp) | |
| print(len(c)) |