IDS-3250 Lecture Notes - Lecture 1: Standard Streams, Node.Js

32 views4 pages

Document Summary

** an array a consisting of n integers is given. A triplet (p, q, r) is triangular if it is possible to build a triangle with sides of lengths a[p], a[q] and a[r]. In other words, triplet (p, q, r) is triangular if 0 p < q < r < n and: A[r] + a[p] > a[q]. function solution(a) { var a0 = a. length; var tricount =0; **a non-empty array a consisting of n numbers is given. The absolute distinct count of this array is the number of distinct absolute values among the elements of the array. The absolute distinct count of this array is 5, because there are 5 distinct absolute values among the elements of this array, namely 0, 1, 3, 5 and 6. Write a function: function solution(a) { var r = []; for(var i = 0; i < a. length; i++) if(!r. includes(math. abs(a[i]))){ r. push(math. abs(a[i])); return r. length; **let a be a non-empty array consisting of n integers.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions