MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / Insert

Method Insert

tasks/380.go:28–35  ·  view source on GitHub ↗

** Inserts a value to the set. Returns true if the set did not already contain the specified element. */

(val int)

Source from the content-addressed store, hash-verified

26
27/** Inserts a value to the set. Returns true if the set did not already contain the specified element. */
28func (this *RandomizedSet) Insert(val int) bool {
29 if _, ok := this.valsSet[val]; !ok {
30 this.valsSet[val] = valEl{val: val, ind: len(this.vals)}
31 this.vals = append(this.vals, val)
32 return true
33 }
34 return false
35}
36
37/** Removes a value from the set. Returns true if the set contained the specified element. */
38func (this *RandomizedSet) Remove(val int) bool {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected