![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
fareast_mzh
善假于物
展开
-
leetcode#215 数组中的第K个最大元素 TopK Top K, TopN, Top N
https://leetcode-cn.com/problems/kth-largest-element-in-an-array 用普通的定长(k)数组作为容器,元素从小到大排列, 遍历列表中的元素,始终维持k个有效元素。 最后取第0个元素就是第k大的元素。 function H(/* int */cap) { this.repo = []; this.cap = cap;...原创 2020-04-17 20:30:57 · 565 阅读 · 0 评论 -
leetcode#1 两数之和
https://leetcode-cn.com/problems/two-sum/ 1. 两数之和 给定一个整数数组nums和一个目标值target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 ...原创 2020-04-17 12:32:37 · 320 阅读 · 0 评论 -
Leetcode#14. Longest Common Prefix
https://leetcode.com/problems/longest-common-prefix/submissions/ Approach 1: Horizontal scanning * Solution.php <?php class Solution { /** * @param $haystack string * @param $...原创 2020-01-21 18:08:39 · 331 阅读 · 1 评论 -
Leetcode#13. Roman to Integer
* Solution.java package com.leetcode.romanToInteger; public class Solution { public int romanToInt(String s) { String t = "IVXLCDM"; int []weight = {1, 5, 10, 50, 100, 500, 10...原创 2020-01-17 17:25:34 · 272 阅读 · 0 评论 -
Leetcode#12 integer-to-roman
https://leetcode.com/problems/integer-to-roman/submissions/ * 12.php <?php class Solution { // a[0] > a[1] > a[2] ... private static function indexLessThan($a, $ans, $start=0...原创 2020-01-10 17:23:22 · 264 阅读 · 0 评论