随笔分类 -  LeetCode

摘要:Description 实现 strStr() 函数。 给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串出现的第一个位置(下标从 0 开始)。如果不存在,则返回 -1 。 说明: 当 needle 是空字符串时,我们应当返回什么值呢? 阅读全文
posted @ 2022-05-19 19:44 arcsinW 阅读(26) 评论(0) 推荐(0) 编辑
摘要:Description 给你两个有序整数数组nums1和nums2,请你将nums2合并到nums1中,使nums1成为一个有序数组。 说明: 初始化nums1和nums2的元素数量分别为m和n。 你可以假设nums1有足够的空间(空间大小大于或等于 m + n)来保存nums2中的元素。 示例: 阅读全文
posted @ 2020-07-01 11:25 arcsinW 阅读(213) 评论(0) 推荐(0) 编辑
摘要:Description Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to c 阅读全文
posted @ 2020-05-27 19:06 arcsinW 阅读(178) 评论(0) 推荐(0) 编辑
摘要:Description Given an array, rotate the array to the right by k steps, where k is non-negative. Follow up: Try to come up as many solutions as you can, 阅读全文
posted @ 2020-05-27 19:05 arcsinW 阅读(116) 评论(0) 推荐(0) 编辑
摘要:Description Given an array , write a function to move all s to the end of it while maintaining the relative order of the non zero elements. Example: N 阅读全文
posted @ 2020-04-11 16:47 arcsinW 阅读(97) 评论(0) 推荐(0) 编辑
摘要:Description Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number on the chalkboard. On each player's turn, 阅读全文
posted @ 2020-01-13 19:37 arcsinW 阅读(274) 评论(0) 推荐(0) 编辑
摘要:Description Given a $m \times n$ grid filled with non negative numbers, find a path from top left to bottom right which minimizes the sum of all numbe 阅读全文
posted @ 2020-01-12 23:31 arcsinW 阅读(89) 评论(0) 推荐(0) 编辑
摘要:Description A robot is located at the top left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or ri 阅读全文
posted @ 2020-01-12 14:45 arcsinW 阅读(156) 评论(0) 推荐(0) 编辑
摘要:Description Given a binary matrix , we want to flip the image horizontally, then invert it, and return the resulting image. To flip an image horizonta 阅读全文
posted @ 2019-11-26 20:18 arcsinW 阅读(130) 评论(0) 推荐(0) 编辑
摘要:Description Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list head = [4,5 阅读全文
posted @ 2019-11-26 12:25 arcsinW 阅读(110) 评论(0) 推荐(0) 编辑
摘要:Description Given an array of integers , write a method that returns the "pivot" index of this array. We define the pivot index as the index where the 阅读全文
posted @ 2019-11-01 14:25 arcsinW 阅读(152) 评论(0) 推荐(0) 编辑
摘要:Given a function which generates a uniform random integer in the range 1 to 7, write a function which generates a uniform random integer in the range 阅读全文
posted @ 2019-09-02 16:13 arcsinW 阅读(206) 评论(0) 推荐(0) 编辑
摘要:Description e Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n = 0. Given , return the value of 阅读全文
posted @ 2019-08-28 18:20 arcsinW 阅读(368) 评论(0) 推荐(0) 编辑
摘要:Description Given a sorted (in ascending order) integer array of elements and a value, write a function to search in . If exists, then return its inde 阅读全文
posted @ 2019-08-21 13:39 arcsinW 阅读(121) 评论(0) 推荐(0) 编辑
摘要:Description You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into 阅读全文
posted @ 2019-08-09 19:10 arcsinW 阅读(119) 评论(0) 推荐(0) 编辑
摘要:Description Given a valid (IPv4) IP , return a defanged version of that IP address. A defanged IP address replaces every period with . Example 1: Exam 阅读全文
posted @ 2019-08-06 11:28 arcsinW 阅读(229) 评论(0) 推荐(0) 编辑
摘要:Description Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Example 2: Example 阅读全文
posted @ 2019-08-05 15:28 arcsinW 阅读(133) 评论(0) 推荐(0) 编辑
摘要:Description Given an array of size $n$, find the majority element. The majority element is the element that appears more than times. You may assume th 阅读全文
posted @ 2019-08-05 11:04 arcsinW 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Description Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to th 阅读全文
posted @ 2019-08-01 11:19 arcsinW 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Description Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) Push element x onto stack. pop() 阅读全文
posted @ 2019-07-31 15:51 arcsinW 阅读(94) 评论(0) 推荐(0) 编辑