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 how_much_does_daytona_costs(): | |
| n, k = map(int, input().split()) | |
| a = list(map(int, input().split())) | |
| if k in a: | |
| return "YES" | |
| return "NO" | |
| t = int(input()) |
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
| """ O(n*n) approach """ | |
| class Solution: | |
| def pairWithMaxSum(self, arr): | |
| # Your code goes here | |
| nums = arr | |
| globalMaxSum = float('-inf') | |
| n = len(nums) | |
| for i in range(n-1): | |
| fMin = nums[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
| int go(int[] a, int l, int r) { | |
| if (l == r) | |
| return a[l]; | |
| int mid = (l + r) / 2; | |
| return go(a, l, mid) + go(a, mid + 1, r); | |
| } | |
| int[] a = {...}; | |
| int N = a.length; |
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: | |
| #User function Template for python3 | |
| #Complete this function | |
| def findFloor(self,A,N,X): | |
| #Your code here | |
| nums = A | |
| x = X | |
| n = N | |
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 target_practice(): | |
| # hardcode the target matrix since it is always 10 * 10 matrix with fixed values | |
| target = [ | |
| [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], | |
| [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], | |
| [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], | |
| [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], | |
| [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], | |
| [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], | |
| [1, 2, 3, 4, 4, 4, 4, 3, 2, 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
| def sequence_game(): | |
| n = int(input()) | |
| b = list(map(int, input().split())) | |
| res = [b[0]] | |
| for i in range(1, n): | |
| if b[i] < b[i - 1]: | |
| res.append(1) | |
| res.append(b[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
| # Write your MySQL query statement below | |
| select p.product_id, ifnull(round(sum(p.price * u.units) / sum(u.units), 2), 0) as average_price | |
| from Prices p left join UnitsSold u on p.product_id=u.product_id and u.purchase_date between p.start_date and p.end_date | |
| group by p.product_id; |
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 long_jumps(): | |
| # input | |
| n = int(input()) | |
| a = list(map(int, input().split())) | |
| # logic | |
| globalMaxScore = float("-inf") | |
| ptr = 0 | |
| while ptr < n: |
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
| # input | |
| n, s = map(int, input().split()) | |
| a = [0] + list(map(int, input().split())) + [0] | |
| b = [0] + list(map(int, input().split())) + [0] | |
| # logic | |
| reachable = False | |
| for i in range(1, n + 1): | |
| if i == 1 and a[i] == 0: | |
| print("NO") |