
LeetCode: 121. Best Time to Buy and Sell Stock
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 transactio[……]
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 transactio[……]
输入一个链表,反转链表后,输出新链表的表头。
ListNode* ReverseList(ListNode* pHead) {
vector<ListNode*> res;
ListNode* temp=nullptr;
res.[......]
输入一个链表,输出该链表中倒数第k个结点。
ListNode* FindKthToTail(ListNode* head, unsigned int k) {
if(!head)return nullptr;
ListNode* tep=head;[......]
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。
void reOrderArray(vector<int> &array) {
ve[......]
Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.
class Solution {
public:
in[......]
Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the hist[……]
Given a sorted linked list, delete all duplicates such that each element appear only once.
和82一样 遍历一遍,但是pre->next移动到cur的位置,不是cur->next的位置
class So[......]
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell, where “adja[……]
Note: The solution set must not contain duplicate subsets.
link: https://leetcode.com/problems/subsets/
[……]