01 2019 档案
摘要:https://leetcode.com/problems/reorganize-string/ Given a string S, check if the letters can be rearranged so that two characters that are adjacent to
阅读全文
摘要:https://leetcode.com/problems/minimum-index-sum-of-two-lists/ Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list
阅读全文
摘要:https://leetcode.com/problems/top-k-frequent-words/ Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted
阅读全文
摘要:https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/ Given a n x n matrix where each of the rows and columns are sorted in ascending
阅读全文
摘要:https://leetcode.com/problems/first-unique-character-in-a-string/ Given a string, find the first non-repeating character in it and return it's index.
阅读全文
摘要:https://leetcode.com/problems/sort-characters-by-frequency/ Given a string, sort it in decreasing order based on the frequency of characters. Example
阅读全文
摘要:https://leetcode.com/problems/sort-list/ Sort a linked list in O(n log n) time using constant space complexity. Example 1: Example 2: 代码: 归并排序 学到了 FHF
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805345078067200 Suppose that all the keys in a binary tree are distinct positive integer
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805344222429184 After each PAT, the PAT Center will announce the ranking of institutions
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805343979159552 A clique is a subset of vertices of an undirected graph such that every
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805343043829760 This is a problem given in the Graduate Entrance Exam in 2018: Which of
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805343727501312 The lowest common ancestor (LCA) of two nodes U and V in a tree is the d
阅读全文
摘要:https://leetcode.com/problems/top-k-frequent-elements/ Given a non-empty array of integers, return the k most frequent elements. Example 1: Example 2:
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/330#question A.Applese 的取石子游戏 #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int N; int
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805342821531648 In computer science, a heap is a specialized tree-based data structure t
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/1038430013544464384 The "travelling salesman problem" asks the following question: "Given a
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/1071785301894295552 A proper vertex coloring is a labeling of the graph's vertices with col
阅读全文
摘要:https://leetcode.com/problems/kth-largest-element-in-an-array/ Find the kth largest element in an unsorted array. Note that it is the kth largest elem
阅读全文
摘要:https://leetcode.com/problems/kth-largest-element-in-a-stream/ Design a class to find the kth largest element in a stream. Note that it is the kth lar
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/1038430130011897856 The lowest common ancestor (LCA) of two nodes U and V in a tree is the
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/1071785408849047552 In computer science, a heap is a specialized tree-based data structure
阅读全文
摘要:https://leetcode.com/problems/spiral-matrix-ii/ Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order
阅读全文
摘要:https://leetcode.com/problems/spiral-matrix/ Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/327#question D.处女座与重修费 代码: #include <bits/stdc++.h> using namespace std; int N; int main() { scanf("%d", &N); int
阅读全文
摘要:https://leetcode.com/problems/lemonade-change/ At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and ord
阅读全文
摘要:https://leetcode.com/problems/assign-cookies/ Assume you are an awesome parent and want to give your children some cookies. But, you should give each
阅读全文
摘要:https://leetcode.com/problems/reverse-vowels-of-a-string/ Write a function that takes a string as input and reverse only the vowels of a string. Examp
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805357933608960 On a broken keyboard, some of the keys are always stucked. So when you t
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805357258326016 Given a set of N (>) positive integers, you are supposed to partition th
阅读全文
摘要:1.摆花问题 题目描述小明的花店新开张,为了吸引顾客,他想在花店的门口摆上一排花,共m盆。通过调查顾客的喜好,小明列出了顾客最喜欢的n种花,从1到n标号。为了在门口展出更多种花,规定第i种花不能超过ai盆,摆花时同一种花放在一起,且不同种类的花需按标号的从小到大的顺序依次摆列。试编程计算,一共有多少
阅读全文
摘要:https://leetcode.com/problems/design-linked-list/ Design your implementation of the linked list. You can choose to use the singly linked list or the d
阅读全文
摘要:https://leetcode.com/problems/linked-list-components/ We are given head, the head node of a linked list containing unique integer values. We are also
阅读全文
摘要:https://leetcode.com/problems/missing-number/ Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing fr
阅读全文
摘要:https://leetcode.com/problems/odd-even-linked-list/ Given a singly linked list, group all odd nodes together followed by the even nodes. Please note h
阅读全文
摘要:https://leetcode.com/problems/add-two-numbers-ii/ You are given two non-empty linked lists representing two non-negative integers. The most significan
阅读全文
摘要:https://leetcode.com/problems/reverse-linked-list/ Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively
阅读全文
摘要:https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ Given a sorted linked list, delete all nodes that have duplicate numbers, leaving
阅读全文
摘要:https://leetcode.com/problems/array-partition-i/ Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1,
阅读全文
摘要:https://leetcode.com/problems/move-zeroes/ Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order
阅读全文
摘要:https://leetcode.com/problems/remove-nth-node-from-end-of-list/ Given a linked list, remove the n-th node from the end of list and return its head. Ex
阅读全文
摘要:https://leetcode.com/problems/swap-nodes-in-pairs/ Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorit
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805348471259136 Recommendation system predicts the preference that a user would give to
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805367987355648 A Binary Search Tree (BST) is recursively defined as a binary tree which
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N student records with name, ID and grade. You are suppo
阅读全文
摘要:https://pintia.cn/problem-sets/994805342720868352/problems/994805440976633856 A Binary Search Tree (BST) is recursively defined as a binary tree which
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/301#question F.小乐乐下象棋 #include <cstdio> #include <cstring> #include <iostream> using namespace std; const long lon
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/322#question A.dreamstart的催促 代码: #include <cstdio> #include <cstring> #include <iostream> using namespace std; con
阅读全文