zoukankan      html  css  js  c++  java
  • 5月18号

      一、保持数组中的每个元素与其索引相互对应的最好方法是什么?哈希表【来源LK】

        1. map.containsKey(complement):Map集合集合中包含这个key么,返回值是boolean。

        2. map.get(complement):Map集合中根据key获取值value.返回值是value。

        3.所谓hash表就是Map集合。

          

        class Solution {

        public int[] twoSum(int[] nums, int target) {

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
        int complement = target - nums[i];
        if (map.containsKey(complement)) {
        return new int[] { map.get(complement), i };
        }
        map.put(nums[i], i);
        }
        throw new IllegalArgumentException("No two sum solution");

        }}

    二 、

      1. Integer.MAX_VALUE

          :java int 类整数的最大值是 2 的 31 次方 - 1 = 2147483648 - 1 = 2147483647

          :Integer.MAX_VALUE + 1 = Integer.MIN_VALUE = -2147483648

    Java 八种基本类型 中表示整数的有:byte、short、int、long 这四种。  (另外四种是 float、double、char、boolean)

    三、

      1. List是队列。

      

  • 相关阅读:
    go timer
    go语言函数作为参数传递
    gomail发送附件
    统计和图片来说话
    一个发邮件的demo 用golang
    Shelled-out Commands In Golang
    阅读笔记
    语言和人收藏
    在线学习网址
    通用首席娱乐官:了解自己是成功的基础
  • 原文地址:https://www.cnblogs.com/wym591273/p/10885950.html
Copyright © 2011-2022 走看看