Skip to content

Latest commit

 

History

History
128 lines (91 loc) · 2.77 KB

File metadata and controls

128 lines (91 loc) · 2.77 KB

mermaid Entity Relationship Diagram

erDiagram
    CAR ||--o{ NAMED-DRIVER : allows
    PERSON ||--o{ NAMED-DRIVER : is
Loading

text's style test

line-through strong italic mark_tag·

print("单行代码测试")

!> p.tip em code

?> docsify的markdown扩充语法

单行引用

Referenced Links

docsify-themeable's index.html.

kbd tag

Ctrl + S : Save file

  • Python
  • Rust
  • PHP

details-summary

题目描述

给定一个整数数组和一个目标值,找出数组中【和为目标值的两个数】,且元素不能重复

Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,

return [0, 1].

docsify-tabs

** Two-pass Hash Table **

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

** One-pass Hash Table **

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");
}

flexible-alerts

Note

An alert of type note.

[!NOTE|style:flat] An alert of type 'note.flat'.

Tip

An alert of type 'tip'

[!TIP|style:flat|label:untitled|iconVisibility:visible] (style:flat), label:untitled, iconVisibility:visible

Warning

This is a warning alert!

[!WARNING|style:flat] (style:flat)This is a warning alert!

[!DANGER] This is a danger alert!

[!DANGER|style:flat] (style:flat)This is a danger alert!


diff block test

- github/vscode support diff block
+ this text is highlighted in green
- this text is highlighted in red