文章 217
评论 6
浏览 143928
73. Set Matrix Zeroes

73. Set Matrix Zeroes

Given an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.

Array - 56. Merge Intervals

Array - 56. Merge Intervals

Given a collection of intervals, merge all overlapping intervals.

LinkedList - 23. Merge k Sorted Lists

LinkedList - 23. Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

重排奇偶有序链表

重排奇偶有序链表

给定一个链表,其中奇数位是升序的,偶数位是降序的,实现链表的排序。

LinkedList - 21. Merge Two Sorted Lists

LinkedList - 21. Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

LinkedList - 328. Odd Even Linked List

LinkedList - 328. Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.

LinkedList - 206. Reverse Linked List

LinkedList - 206. Reverse Linked List

Reverse a singly linked list.

LinkedList - 92. Reverse Linked List II

LinkedList - 92. Reverse Linked List II

Reverse Linked List II Reverse a linked list from position m to n. Do it in one-pass. **Note: **1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2->5->NULL 思路: 找到m的前一位,然后翻转n-m+1个节点,链表翻转类型的题目常规套路都是使用一个dummy来保存head链表头。因为题目说了链表长度比m和n都要大,所以不用额外关注m和n会不会导致空指针。 代码: java: /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { publ....

接口实现幂等的几种方式

接口实现幂等的几种方式

最近处理的单据业务经常会因为接口不幂等导致数据出错的情况。所以幂等性在设计系统的时候一定要考虑进去,尤其是像支付宝、银行、互联网金融公司等涉及的都是钱的系统,既要高效,也要准确,所以不能出现多扣款、多打款等问题,不然这样会很难处理,用户体验也不会好。

LinkedList - 25. Reverse Nodes in k-Group

LinkedList - 25. Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

Design - 146. LRU Cache

Design - 146. LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.

1496. Path Crossing

1496. Path Crossing

Return True if the path crosses itself at any point, that is, if at any time you are on a location you've previously visited. Return False otherwise.

Math - 50. Pow(x, n)

Math - 50. Pow(x, n)

Implement pow(x, n), which calculates x raised to the power n (xn).

680. Valid Palindrome II

680. Valid Palindrome II

Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.

Palindrome - 125. Valid Palindrome

Palindrome - 125. Valid Palindrome

Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

LinkedList - 142. Linked List Cycle II

LinkedList - 142. Linked List Cycle II

Given a linked list, return the node where the cycle begins.

LinkedList - 876. Middle of the Linked List

LinkedList - 876. Middle of the Linked List

Given a non-empty, singly linked list with head node head, return a middle node of linked list.

golang 内存分析/内存泄漏

golang 内存分析/内存泄漏

当golang程序在运行过程中消耗了超出预期内存时,需要搞明白,到底是程序中哪些代码导致了这些内存消耗。此时,通常可以采用golang的pprof来分析golang进程的内存使用。

golang gctrace分析gc过程

golang gctrace分析gc过程

gctrace主要是用于跟踪GC的不同阶段的耗时与GC前后的内存量对比。可以用于对runtime本身进行调试之外,还可以观察线上应用的GC情况。

golang 标准库 time/rate 介绍

golang 标准库 time/rate 介绍

golang官方库中有一个rate包,实现了令牌桶算法。

Nothing just happens, it's all part of a plan.