随笔分类 - leetcode 刷题笔记
摘要:leetcode刷题笔记三十三 搜索旋转排序数组 源地址: "33. 搜索旋转排序数组" 问题描述: 假设按照升序排序的数组在预先未知的某个点上进行了旋转。( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。 搜索一个给定的目标值,如果数组中存在这个目标值,
阅读全文
摘要:leetcode刷题笔记三十二 最长有效括号 源地址: "32. 最长有效括号" 问题描述: 给定一个只包含 '(' 和 ')' 的字符串,找出最长的包含有效括号的子串的长度。 示例 1: 输入: "(()" 输出: 2 解释: 最长有效括号子串为 "()" 示例 2: 输入: ")()())" 输
阅读全文
摘要:leetcode刷题笔记三十一 下一个排列 源地址: "31. 下一个排列" 问题描述: 实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 必须原地修改,只允许使用额外常数空间。 以下是一些
阅读全文
摘要:leetcode刷题笔记三十 串联所有单词的子串(待优化) 源地址: "30. 串联所有单词的子串" 问题描述: 给定一个字符串 s 和一些长度相同的单词 words。找出 s 中恰好可以由 words 中所有单词串联形成的子串的起始位置。 注意子串要与 words 中的单词完全匹配,中间不能有其他
阅读全文
摘要:leetcode刷题笔记二十九 两数相除 源地址: "两数相除" 问题描述: 给定两个整数,被除数 dividend 和除数 divisor。将两数相除,要求不使用乘法、除法和 mod 运算符。 返回被除数 dividend 除以除数 divisor 得到的商。 整数除法的结果应当截去(trunca
阅读全文
摘要:leetcode刷题笔记二十六 、 二十七、 二十八 leetcode刷题笔记二十六 删除排序数组中的重复项 scala版 源地址: "26. 删除排序数组中的重复项" 问题描述: 给定一个排序数组,你需要在 原地 删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。 不要使用额外的
阅读全文
摘要:leetcode刷题笔记二十五 K 个一组翻转链表 Scala版本 源地址: "25. K 个一组翻转链表" 问题描述: 给你一个链表,每 k 个节点一组进行翻转,请你返回翻转后的链表。 k 是一个正整数,它的值小于或等于链表的长度。 如果节点总数不是 k 的整数倍,那么请将最后剩余的节点保持原有顺
阅读全文
摘要:leetcode刷题笔记二十四 两两交换链表中的节点 Scala版本 源地址: "24. 两两交换链表中的节点" 问题描述: Given a linked list, swap every two adjacent nodes and return its head. You may not mod
阅读全文
摘要:leetcode刷题笔记二十三 合并K个排序链表 Scala版本 源地址: "23. 合并K个排序链表" 问题描述: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its comp
阅读全文
摘要:leetcode刷题笔记二十二 括号生成 Scala版本 源地址: "22. 括号生成" 问题描述: Given n pairs of parentheses, write a function to generate all combinations of well formed parenthe
阅读全文
摘要:leetcode刷题笔记二十一 合并两个有序列表 Scala版本 源地址: "21. 合并两个有序链表" 问题描述: 将两个升序链表合并为一个新的升序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例: 输入:1 2 4, 1 3 4 输出:1 1 2 3 4 4 代码补充:
阅读全文
摘要:leetcode刷题笔记二十 有效的括号 Scala版本 源地址: "20. 有效的括号" 问题描述: Given a string containing just the characters , , , , and , determine if the input string is valid
阅读全文
摘要:leetcode刷题笔记十九 删除链表的倒数第N个节点 Scala版本 源地址: "19. 删除链表的倒数第N个节点" 问题描述: Given a linked list, remove the n th node from the end of list and return its head.
阅读全文
摘要:leetcode刷题笔记十八 四数之和 Scala版本 源地址: "18. 四数之和" 问题描述: Given an array of n integers and an integer , are there elements a , b , c , and d in such that a +
阅读全文
摘要:leetcode刷题笔记十七 电话号码的组合 Scala版本 源地址: "17. 电话号码的字母组合" 题目描述: Given a string containing digits from inclusive, return all possible letter combinations tha
阅读全文
摘要:leetcode刷题笔记十六 接近三数之和 Scala版本 源地址: "16. 最接近的三数之和" 问题描述: Given an array of n integers and an integer , find three integers in such that the sum is clos
阅读全文
摘要:leetcode刷题笔记十五 三数之和 Scala版本 源地址:15. 三数之和 问题描述: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all
阅读全文
摘要:leetcode刷题笔记十四 最长公共前缀 Scala版本 源地址:最长公共前缀 问题描述: Write a function to find the longest common prefix string amongst an array of strings. If there is no c
阅读全文
摘要:leetcode刷题笔记十三 罗马数字转数字 Scala版本 源地址:罗马数字转数字 问题描述: oman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V
阅读全文
摘要:leetcode刷题笔记十二 整数转罗马数字 Scala版本 源地址:整数转罗马数字 问题描述: Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V
阅读全文
浙公网安备 33010602011771号