C++
15332019张胜利
这个作者很懒,什么都没留下…
展开
-
分而治之——找出第K大的数
问题描述:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2Output...原创 2018-09-16 14:39:19 · 321 阅读 · 0 评论 -
Search Insert Position
问题描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the a...原创 2018-12-29 11:24:52 · 117 阅读 · 0 评论 -
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.Example:Input: 1->2->4, 1->3->4Out...原创 2018-12-29 10:57:37 · 97 阅读 · 0 评论 -
Remove Duplicates from Sorted Array
问题描述:Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by ...原创 2018-12-29 10:45:43 · 102 阅读 · 0 评论 -
Implement strStr()
问题描述:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2...原创 2018-12-29 10:33:23 · 99 阅读 · 0 评论 -
Add Two Numbers
问题描述:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and r...原创 2018-12-29 10:23:55 · 98 阅读 · 0 评论 -
整数转罗马数字
问题描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-12-02 22:52:22 · 104 阅读 · 0 评论 -
Longest Common Prefix
问题描述:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Input: ["flower","flow","flight"]...原创 2018-11-18 23:37:11 · 71 阅读 · 0 评论 -
罗马数字转换
问题描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-11-11 23:31:09 · 644 阅读 · 0 评论 -
反转数
问题描述:Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we ...原创 2018-11-11 23:26:16 · 147 阅读 · 0 评论 -
平衡二叉树
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never differ by more than 1.Example 1:Given the following tree [3,9原创 2018-10-21 21:49:22 · 103 阅读 · 0 评论 -
TWO Sum
问题描述:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use th...原创 2018-10-28 21:18:49 · 104 阅读 · 0 评论 -
Intersection of Two Linked Lists
问题描述:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ ...原创 2018-10-14 22:56:24 · 93 阅读 · 0 评论 -
二叉树的深度
问题描述: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 farthest leaf node.Note: A leaf is a node with no ...原创 2018-10-07 23:10:45 · 83 阅读 · 0 评论 -
判断二叉树是否相同
问题描述:Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.E...原创 2018-10-07 22:54:59 · 323 阅读 · 0 评论 -
Remove Element
问题描述:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the inp...原创 2018-12-29 21:21:41 · 116 阅读 · 0 评论