OneCoder Avatar
OneCodercoderli.com · 936 篇博文
🧮

算法专题与 LeetCode

49

常用数据结构、双指针滑动窗口、动态规划与二分搜索。

🎯分类筛选(显示 49 / 共 49 篇)
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Rising Temperature

Problem Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates. For example, retur...

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··7 分钟

LeetCode Implement Queue Using Stacks

Problem Implement the following operations of a queue using stacks. Example: Notes: You must use only standard operations of a stack -- which means only push to...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Power of Two

Problem Given an integer, write a function to determine if it is a power of two. Example 1: Example 2: Example 3: 判断一个整数是否是2的幂次方 <!--break-- Python3 分析 给出两种办法。一...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Invert Binary Tree

Problem Invert a binary tree. Example: 对树进行完全的左右节点交换 <!--break-- Python3 分析 很自然的想到了递归

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··7 分钟

LeetCode Implement Stack using Queue

Problem Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top(...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Contains Duplicate II

Problem Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the ab...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Contains Duplicate

Problem Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··5 分钟

LeetCode Reverse Linked List

Problem Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 即反转链表,建议采用递...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Isomorphic Strings

Problem Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Count Primes

Problem Description: Count the number of prime numbers less than a non-negative number, n. 即统计小于n的质数个数 <!--break-- Python3 分析 采用空间换时间的方式。否则会超时。

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Remove Linked List Elements

Problem Remove all elements from a linked list of integers that have value val. Example Given: 1 -- 2 -- 6 -- 3 -- 4 -- 5 -- 6, val = 6 Return: 1 -- 2 -- 3 -- 4...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Happy Number

Problem Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer,...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode House Robber

Problem You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Tenth Line

Problem How would you print just the 10th line of a file? For example, assume that file.txt has the following content: Your script should output the tenth line,...

#LeetCode#Bash
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Delete Duplicate Emails

Problem Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. For example, after...

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Valid Phone Number

Problem Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers. You may a...

#LeetCode#Bash
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Number of 1 Bits

Problem Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit in...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Reverse Bits

Problem Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··5 分钟

LeetCode Rotate Array

Problem Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note:...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Nth Highest Salary

Problem Write a SQL query to get the nth highest salary from the Employee table. For example, given the above Employee table, the nth highest salary where n = 2...

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Employees Earning More Than Their Managers

Problem The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. Given the Empl...

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Duplicate Emails

Problem Write a SQL query to find all duplicate emails in a table named Person. For example, your query should return the following for the above table: 找到重复的Em...

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Customers Who Never Order

Problem Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything....

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Second Highest Salary

Problem Write a SQL query to get the second highest salary from the Employee table. For example, given the above Employee table, the query should return 200 as...

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Combine Two Tables

Problem Table: Person Table: Address Write a SQL query for a report that provides the following information for each person in the Person table, regardless if t...

#LeetCode#SQL
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Factorial Trailing Zeroes

Problem Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 即计算n!末尾0的个数。要求用对数时间复杂度 <!-...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Majority Element

Problem Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the a...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Excel Sheet Column Title

Problem Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 即生成Excel表格的表头 <!--break-- Python 实现 分析 讲不出太多道理...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Excel Sheet Column Number

Problem Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: 即从Ex...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··5 分钟

LeetCode Two Sum II - Input array is sorted

Problem Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function t...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··8 分钟

LeetCode Intersection of Two Linked List

Problem Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to inte...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··6 分钟

LeetCode Min Stack

Problem Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··6 分钟

LeetCode Linked List Cycle II

Problem Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up: Can you...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Linked List Cycle

Problem Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 判断一个链表中是否存在 环,不开辟额外的空间 <!--break-- Python...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Single Number II

Problem Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm sho...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··2 分钟

LeetCode Single Number

Problem Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexi...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··5 分钟

LeetCode Valid Palindrome

Problem Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Pana...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··5 分钟

LeetCode Best Time to Buy and Sell Stock

Problem Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··5 分钟

LeetCode Best Time to Buy and Sell Stock II

Problem Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Pascal's Triangle II

Problem Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to us...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··3 分钟

LeetCode Pascal's Triangle

Problem Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return 没记错的话,这个应该叫杨辉三角型。很简单的题 <!--break-- Python 实现 分析 没...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··5 分钟

LeetCode Path Sum II

Problem Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and sum...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Path Sum

Problem Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··4 分钟

LeetCode Minimum Depth of Binary Tree

Problem Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest lea...

#LeetCode#Python
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··6 分钟

LeetCode[Algorithms] Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(...

#算法#LeetCode
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··9 分钟

LeetCode[Algorithms] Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers suc...

#算法#LeetCode
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··8 分钟

LeetCode[Algorithms] Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add...

#算法#LeetCode
🧮 Algo数据结构与算法
算法与 LeetCode 专题 · 核心算法··18 分钟

数据结构 有序数组表示稀疏矩阵

<p 一般存储矩阵,自然想到二维数据。但是对于稀疏矩阵(0项很多),这无疑浪费的大量的空间。所以,这里考虑换一种表示方法。用一个三元组表示矩阵中的非零元素。</p <p style="text-align: center;" <img alt="" src="/images/oldposts/a7iq6.jpg" st...

#数据结构
🧮 Algo数据结构与算法