messages
listlengths
3
3
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: \nGiven an array nums and an integer target, return the maximum number of non-empty non-...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def most_common_subsequence(S: str) -> str:\n \"\"\" \n Find the most common repea...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Optional\n\ndef first_non_repeating(arr: List[int]) -> Optional...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def largest_rectangle_area(matrix: List[str]) -> int:\n \"\"\" \n Find the largest...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\n\nYou are tasked with implementing a function that calculates the...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Circular Phonetic Encoder\\n\\n**Problem Statement**\\nA covert agency stores its co...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Given a matrix of characters `board` and a string `word`, return `true` _if_ `word` _exi...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem: Cache Simulator with LRU Replacement Policy\n\n**Scenario**: \nYou are task...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\nImplement a `CharacterCounter` class that allows you to count the...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given a list of strings `words` and a string `target`. A concatenated string is ...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Complete the following python code: ```python\nimport matplotlib.pyplot as plt\nfrom matplotlib.figure import Figure\n\ndef ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: \nGiven two integer arrays nums1 and nums2, return the maximum length of a subarray that...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def max_average_speed(n: int, k: int, speeds: List[int]) -> float:\n \"\"\"\n Retu...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Given an array nums of integers, return the number of good pairs.\nA pair (i, j) is call...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def longest_consecutive_subsequence(t: int, data: List[Tuple[int, List[int]]]) -> List[i...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def compute_grade(score: int) -> str:\n \"\"\" Return the letter grade based on the s...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Route Success\n\nA logistics company manages **n** delivery routes. Route *i* passes...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Given two positive integers n and x.\nReturn the number of ways n can be expressed as th...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Covert Morse Transmission\n\nIn a secret Morse‑communication network, every lower‑ca...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\nYou are in charge of a real‑time monitoring system that keeps the ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def are_indirectly_connected(n: int, m: int, connections: List[Tuple[int, int]], q: int,...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def recommend_friends(user_id, friendships):\n \"\"\"\n Recommends friends based o...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def calculate_bonus(records):\n \"\"\" \n Calculate the end-of-year bonus for each...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def min_smallest_palindromic_partition_length(s: str) -> int:\n \"\"\" Given a string...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Union\n\ndef arrange_books(number_of_books: int, book_series: L...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Lexicographically Minimal Version Tags\n\n**Time Limit:** 1 second\n**Memory Limit:*...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Two friends Alex and Bob are playing a game with an array of integers. They take turns p...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\nYou are a logistics planner for a large fruit‑harvesting company....
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: \nYou are given a perfect binary tree where all leaves are on the same level, and every ...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: import numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef task_func(dat...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: An e-commerce company tracks the sales of its products using a daily log record. The sal...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\nYou are in charge of a real‑time booking system for a huge timelin...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def find_isolated_transactions(n: int, m: int, categories: List[int], dependencies: List...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given an unsorted list of integers that may contain duplicates. Write a function...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Description\nYou are working with a remote data service that stores a **stric...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def find_min_radius(houses: List[int], heaters: List[int]) -> int:\n \"\"\" \n Ret...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Circular Log Buffer\n\n### Problem Statement\nYou are hired to implement the core of ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Island Explorer\n\n**Problem Statement**\n\nAn adventurous explorer is stranded on a...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Write a program to find the maximum length of a contiguous subarray with equal number of...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: \nYou are given a 0-indexed array of positive integers nums.\nA subarray of nums is call...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Tuple\nimport sys\nfrom collections import defaultdict\n\ndef f...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: # Convert a linked list to a string\n\n## Related Kata\n\nAlthough this Kata is not part...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: \nGiven an array of points where points[i] = [xi, yi] represents a point on the X-Y plan...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def harmonious_pairs_count(N: int, K: int, colors: List[int]) -> int:\n \"\"\"\n R...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Question: Create a Thread-Safe Singleton Logger Class\n\nImplement a thread-safe sin...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def grade_students(n: int, student_scores: List[Tuple[int, int]]) -> Tuple[List[str], st...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\nYou are in charge of the real‑time leaderboard of an online compet...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\nA rectangular floor consists of `N` rows and `M` columns of unit s...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def bike_sharing(n, initial_bikes, m, requests):\n \"\"\"Manage a log of bike sharing...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\nYou are implementing the **constant‑folding** phase of a compiler....
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Dynamic Pattern Detector\n\n**Time Limit:** 2 seconds\n\n**Memory Limit:** 256 MB\n\...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List\n\ndef shortest_path(grid: List[List[int]], si: int, sj: int, ti...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Closest Waypoints\n\n**Problem Statement**\n\nA navigation system stores the positio...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Burst Product Queries\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 512 MB\n\n### P...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\nYou are given a multiset of `N` iron ingots, where the weight of ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Interactive Problem – Remainder Duel\n\n### Statement\nVasya wants to discover a secr...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Trending Hashtags\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 256 MB\n\n#### Pro...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def can_reach_destination(grid, start, goal) -> bool:\n \"\"\" Determine whether the ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Minimum Toll Payment\n\nA logistics company operates a single delivery route that vi...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### In‑Place Merge and Rank Queries\n\n**Time Limit:** 1 second \n**Memory Limit:** 256...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Lexicographically Minimal Transmission\n\n**Time Limit:** 1 second\n\n**Memory Limit...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: You are given a string `s` and an array of strings `words`. Each string in `words` can b...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Minimum Cooling Breaks\n\n**Time limit:** 1 second\n**Memory limit:** 256 MB\n\n####...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Two Non‑Overlapping Stock Trades\n\n**Problem Statement**\n\nA hedge‑fund analyst has...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def largest_connected_component_size(N: int, M: int, edges: List[Tuple[int, int]]) -> in...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Masha has a rectangular grid of size n × m and q queries. Initially, all the cells in th...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def can_remove_one_to_palindrome(s: str) -> bool:\n \"\"\" Determine if we can remove...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Shortest Excerpt Covering Keywords\n\n**Problem Statement**\nYou are working on a tex...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Alice is participating in a programming contest. One of the problems in the contest requ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def find_min_trees_to_cut(n: int, heights: List[int]) -> int:\n \"\"\"Determine the m...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Problem Statement\nYou are in charge of a real‑time analytics server. The server con...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Write a function called `balance_brackets` that takes a single string containing various...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: **Problem Statement**\\nA satellite continuously transmits telemetry packets, each ident...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Bookstore Inventory Queries\n\n**Time Limit:** 1 second\n**Memory Limit:** 256 MB\n\...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def find_articulation_points(n: int, m: int, edges: List[Tuple[int, int]]) -> int:\n ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List\n\ndef min_steps_to_border(n: int, m: int, grid: List[str]) -> i...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Truncate Massive Keys\n\n**Time Limit:** 2 seconds \n**Memory Limit:** 256 MB\n\n##...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Tuple\n\ndef min_meeting_rooms(meetings: List[Tuple[int, int]])...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def insert_into_min_heap(heap: List[int], value: int) -> List[int]:\n \"\"\" Insert a...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\nYou are given a network of **one‑way routers**. The network consis...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def longest_repeated_subsequence(s: str) -> int:\n \"\"\" Determine the length of the...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: The United Islands is a small nation with n islands numbered from 1 to n. Some islands a...
[ { "role": "system", "content": "You will complete a python code block to implement the desired function. You will only write code blocks." }, { "role": "user", "content": "Complete the following python code: def freq_element(test_tup)::\n \"\"\" Write a function to find the frequency of each ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def maximum_product_of_three(nums: List[int]) -> int:\n \"\"\" Returns the maximum pr...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Problem Title: Exact K Distinct Actions in Subarrays\n\n**Time Limit:** 1 second\n**Memo...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Dynamic Palindrome Checker\n\n**Time Limit:** 2 seconds\n**Memory Limit:** 256 MB\n\n...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Best Counter Pick\n\n**Time Limit:** 1 second \n**Memory Limit:** 256 MB\n\n### Stat...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: A network has multiple nodes, and these nodes are connected by weighted edges. Each node...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: Write a function to convert an integer into a roman numeral.\nTest case 1:\nInput:\n1\nO...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def is_palindrome(s: str) -> bool:\n \"\"\" Returns True if the given string s is a p...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def count_symmetric_banners(M: int) -> int:\n \"\"\" \n Determine the maximum numb...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: import re\n\ndef is_valid_palindrome(s: str) -> str:\n \"\"\" Checks if the given str...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Question: Build a Custom HashMap with Automatic Resizing\n\n#### Context\nA HashMap ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def total_raw_materials(n: int, component_info: List[Tuple[int, int]], m: int) -> int:\n...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Circular Linked List Insertion and Traversal\n\nYou are asked to manage a circular s...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Coding Challenge\n\n**Scenario**: You are given an array of integers, which represen...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ### Scrabble Tiles – Maximum Score Subset\n\nYou are given a small dictionary of words, ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: def is_prime(n: int) -> bool:\n \"\"\" Determines if a number is a prime number.\n ...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: from typing import List, Tuple\n\ndef find_most_loyal_customer(order_data: List[Tuple[in...
[ { "role": "system", "content": "You will write python program to solve algorithm problems. You will only write code blocks." }, { "role": "user", "content": "Write python code to solve the following problem: ## Problem Statement\n\nTwo independent timers are installed in a high‑precision control...