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
| --1st solution | |
| select warehouse, count(warehouse) as number_of_boxes | |
| from boxes | |
| group by warehouse | |
| union ( | |
| select code, '0' | |
| from warehouses | |
| where code not in ( | |
| select warehouse | |
| from boxes |
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
| fun String.withPrevious(): Sequence<Element> { | |
| val string = this | |
| return sequence { | |
| for (i in string.indices) { | |
| val current = string[i] | |
| val previous = if (i > 0) string[i - 1] else null | |
| yield(Element(current, previous)) | |
| } | |
| } | |
| } |
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
| Remove cart by anonymousId | |
| val carts = apiRoot.carts().get().addWhere( | |
| "anonymousId = :anonymousCustomerId", | |
| "anonymousCustomerId", | |
| anonymousCustomerId | |
| ).execute().get().body.results | |
| for (cart in carts) { | |
| apiRoot.carts() |
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
| kubectl apply -f - <<EOF | |
| kind: PersistentVolumeClaim | |
| apiVersion: v1 | |
| metadata: | |
| name: trading-bot-gke-persistent-volume-claim | |
| namespace: default | |
| labels: | |
| app: trading-bot-gke | |
| component: master | |
| spec: |
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 asyncio | |
| from telethon.sync import TelegramClient, events | |
| async def list_groups(): | |
| api_id = 111111111 | |
| api_hash = '11111111eeeeee' | |
| phone = '+8111111111' | |
| client = TelegramClient(phone, api_id, api_hash) | |
| await client.connect() |
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
| fun main() { | |
| val strs = arrayOf("eat", "tea", "tan", "ate", "nat", "bat", "aaaaab") | |
| println(groupAnagramsRedundantly(strs)) | |
| } | |
| fun groupAnagramsRedundantly(strings: Array<String>): List<List<String>> { | |
| val groupedAnagramsMap = hashMapOf<Any, MutableList<String>>() | |
| for (string in strings) { | |
| val anagramKey = findAnagramKeyMutableListRepresentation(string) | |
| val list = groupedAnagramsMap.getOrPut(anagramKey) { mutableListOf() } |
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
| fun topKFrequent(numbers: IntArray, k: Int): IntArray { | |
| val map = numbers.toList().groupingBy { it }.eachCount() | |
| val priorityQueue = PriorityQueue<Pair<Int, Int>>(compareBy { it.second }) | |
| map.forEach { (number, count) -> | |
| priorityQueue.offer(Pair(number, count)) | |
| if (priorityQueue.size > k) { | |
| priorityQueue.poll() | |
| } | |
| } | |
| return IntArray(k) { priorityQueue.poll().first } |
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 os | |
| def print_directory_tree(startpath): | |
| for root, dirs, files in os.walk(startpath): | |
| dirs[:] = [d for d in dirs if d not in ['gradle', 'build', '.idea', '.gradle']] | |
| level = root.replace(startpath, '').count(os.sep) | |
| indent = ' ' * 4 * (level) | |
| print('{}{}/'.format(indent, os.path.basename(root))) | |
| sub_indent = ' ' * 4 * (level + 1) | |
| for f in files: |
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
| tensorflow==2.7.0 | |
| scikit-learn==1.0.1 | |
| pandas==1.1.5 | |
| matplotlib==3.2.2 | |
| seaborn==0.11.2 |
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
| package org.example | |
| fun main() { | |
| createQueue(createStack(), createStack()).apply { | |
| push(1) | |
| push(2) | |
| push(3) | |
| pop() | |
| peek() | |
| pop() |
OlderNewer