随笔分类 - LeetCode
摘要:题目描述:(链接)Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be i...
阅读全文
摘要:题目描述:(链接)Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last...
阅读全文
摘要:题目描述:(链接)Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.解题思路: 1 class Sol...
阅读全文
摘要:题目描述: (链接)GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [...
阅读全文
摘要:题目描述:(链接)Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sort...
阅读全文
摘要:题目描述:(链接)Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Y...
阅读全文
摘要:题目描述:(链接)Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. ...
阅读全文
摘要:题目描述:(链接)Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->N...
阅读全文
摘要:题目描述:(链接)Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Give...
阅读全文
摘要:题目描述:(链接)Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -...
阅读全文
摘要:题目描述:(链接)Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3...
阅读全文
摘要:题目描述:(链接)Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve ...
阅读全文
摘要:题目描述:(链接)Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume tha...
阅读全文
摘要:题目描述:(链接)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 the fa...
阅读全文
摘要:题目描述:(链接)Reverse a singly linked list.解题思路:链表真讨厌,总是出错。头插法。 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *...
阅读全文
摘要:题目描述:(链接)Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5...
阅读全文
摘要:题目描述:(链接):Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For examp...
阅读全文
摘要:题目描述:(链接)There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the follow...
阅读全文
摘要:题目描述:(链接)There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it c...
阅读全文
摘要:题目描述:(链接)Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra ...
阅读全文

浙公网安备 33010602011771号