
算法编程题
JimmyU1
Work Twice as hard as others.
展开
-
LeetCode-removeOuterParentheses
问题描述概括一下就是去除由多层括号组成的字符串中最外层的括号。以下是原文描述:Return S after removing the outermost parentheses of every primitive string in the primitive decomposition of S.Example 1:Input: "(()())(())"Output: "()()()...原创 2019-11-17 15:45:41 · 238 阅读 · 1 评论 -
用两个栈实现队列
用两个栈实现队列1. 题目描述用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。 考察内容:队列,栈2. 解题思路栈是一种后进先出的数据结构队列是一种先进先出的数据结构当一个元素位于队列的front和栈的top时,会被率先退出数据结构一个元素会率先被存储在栈的top和队列的rear因此,当两个栈中存储以相反的次序存储相同的元素时,就实现了队列3.原创 2017-05-08 23:42:47 · 568 阅读 · 0 评论 -
链表中倒数第k个结点
链表中倒数第k个结点1. 题目描述输入一个链表,输出该链表中倒数第k个结点。2. 解题思路由于是单链表,遍历链表只能顺序遍历,也不能随机的访问要求输出的是倒数第K个结点,可以将其换算成正向数的结点首先需要计算出链表中一共有多少个结点节点数减k就是该结点在链表中的位置(从0开始)正向遍历链表即可解决问题3. 解题代码/*public class ListNode { int va原创 2017-05-18 20:32:53 · 595 阅读 · 0 评论 -
LeetCode-Add Two Numbers
LeetCode-Add Two NumbersDescriptionYou 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原创 2018-01-11 11:50:11 · 240 阅读 · 0 评论