摘要:
改进版快排,pivot 不再是左边第一个元素,而是正中间元素(或者随机)。 有一个比较坑的地方就是,在每一趟双指针完成所有交换后,需要判断 pivot 需不需要被交换。 比如 test case 1 2 4 3,第一趟开始时 pivot 是 2, 先动右边的指针 j, 找到第一个比 2 小的数也就是 阅读全文
摘要:
Description Given an array A of integers, return the number of (contiguous, non empty) subarrays that have a sum divisible by K. Example 1: Note: 1 思路 阅读全文
摘要:
Description Given an array of integers and an integer k, you need to find the number of unique k diff pairs in the array. Here a k diff pair is define 阅读全文
摘要:
Description Given a singly linked list, determine if it is a palindrome. Example 1: Example 2: Follow up: Could you do it in O(n) time and O(1) space? 阅读全文
摘要:
Description Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies 阅读全文
摘要:
Description Given an array of non negative integers, you are initially positioned at the first index of the array. Each element in the array represent 阅读全文
摘要:
Description Given an array of non negative integers, you are initially positioned at the first index of the array. Each element in the array represent 阅读全文
摘要:
Description Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between 阅读全文
摘要:
Description Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compu 阅读全文
摘要:
Description Given an array of citations (each citation is a non negative integer) of a researcher, write a function to compute the researcher's h inde 阅读全文