-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp-problems-hr.txt
More file actions
2866 lines (2276 loc) · 74.5 KB
/
cpp-problems-hr.txt
File metadata and controls
2866 lines (2276 loc) · 74.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
----------
CPP.1
easy
----------
PROBLEM STATEMENT:
Objective
This is a simple challenge to help you practice printing to stdout. You may also want to complete Solve Me First in C++ before attempting this challenge.
We're starting out by printing the most famous computing phrase of all time! In the editor below, use either printf or cout to print the string [expression] to stdout.
----------
TOP SOLUTION:
----------
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
printf("Hello, World!");
return 0;
}
----------
====================
----------
CPP.2
easy
----------
PROBLEM STATEMENT:
Objective
In this challenge, we're practicing reading input from stdin and printing output to stdout.
In C++, you can read a single whitespace-separated token of input using cin, and print output to stdout using cout. For example, let's say we declare the following variables:
[expression]
[expression]
and we want to use cin to read the input "High 5" from stdin. We can do this with the following code:
[expression]
The above code reads the first word ("High") from stdin and saves it as string [expression]. If we want to print these values to stdout, we write the following code:
[expression]
The above code prints the contents of string [expression]. Because we also want to ensure that nothing else is printed on this line, we end our line of output with a newline via endl. This results in the following output:
High 5
Task
Read [expression] numbers from stdin and print their sum to stdout.
Note: If you plan on completing this challenge in C instead of C++, you'll need to use format specifiers with printf and scanf.
----------
TOP SOLUTION:
----------
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int s = 0;
int t;
while(cin>>t){
s+=t;
}
cout<<s;
return 0;
}
----------
====================
----------
CPP.3
easy
----------
PROBLEM STATEMENT:
Some C++ data types, their format specifiers, and their most common bit widths are as follows:
Int ("%d"): 32 Bit integer
Long ("%ld"): 64 bit integer
Char ("%c"): Character type
Float ("%f"): 32 bit real value
Double ("%lf"): 64 bit real value
Reading
To read a data type, use the following syntax:
scanf("`format_specifier`", &val)
For example, to read a character followed by a double:
char ch;
double d;
scanf("%c %lf", &ch, &d);
For the moment, we can ignore the spacing between format specifiers.
Printing
To print a data type, use the following syntax:
printf("`format_specifier`", val)
For example, to print a character followed by a double:
char ch = 'd';
double d = 234.432;
printf("%c %lf", ch, d);
Note: You can also use cin and cout instead of scanf and printf; however, if you are taking a million numbers as input and printing a million lines, it is faster to use scanf and printf.
----------
TOP SOLUTION:
----------
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int a;
long b;
long long c;
char d;
float e;
double f;
cin >> a >> b >> c >> d >> e >>f;
cout << a << endl << b << endl << c << endl << d << endl;
printf("%f\n%lf\n", e, f);
return 0;
}
----------
====================
----------
CPP.4
easy
----------
PROBLEM STATEMENT:
if and else are two of the most frequently used conditionals in C/C++, and they enable you to execute zero or one conditional statement among many such dependent conditional statements. We use them in the following ways:
if: This executes the body of bracketed code starting with [expression] evaluates to true.
if (condition) {
statement1;
...
}
if - else: This executes the body of bracketed code starting with [expression] evaluates to false. Note that only one of the bracketed code sections will ever be executed.
if (condition) {
statement1;
...
}
else {
statement2;
...
}
if - else if - else: In this structure, dependent statements are chained together and the [expression] in the chain evaluates to false, then the body of bracketed code in the else block at the end is executed.
if(first condition) {
...
}
else if(second condition) {
...
}
.
.
.
else if((n-1)'th condition) {
....
}
else {
...
}
Given a positive integer denoting [expression], do the following:
If [expression], etc.).
If [expression], print Greater than 9.
----------
TOP SOLUTION:
----------
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
vector<string> arr;
arr.push_back("zero");
arr.push_back("one");
arr.push_back("two");
arr.push_back("three");
arr.push_back("four");
arr.push_back("five");
arr.push_back("six");
arr.push_back("seven");
arr.push_back("eight");
arr.push_back("nine");
int n;
cin >> n;
if(n > 9) cout << "Greater than 9" << endl;
else cout << arr[n] << endl;
return 0;
}
----------
====================
----------
CPP.5
easy
----------
PROBLEM STATEMENT:
A for loop is a programming language statement which allows code to be repeatedly executed.
The syntax for this is
for ( ; ; )
expression_1 is used for intializing variables which are generally used for controlling terminating flag for the loop.
expression_2 is used to check for the terminating condition. If this evaluates to false, then the loop is terminated.
expression_3 is generally used to update the flags/variables.
A sample loop will be
for(int i = 0; i < 10; i++) {
...
}
----------
TOP SOLUTION:
----------
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main() {
vector<string> arr;
arr.push_back("zero");
arr.push_back("one");
arr.push_back("two");
arr.push_back("three");
arr.push_back("four");
arr.push_back("five");
arr.push_back("six");
arr.push_back("seven");
arr.push_back("eight");
arr.push_back("nine");
int a, b;
cin >> a >> b;
for(int i = a;i<=b;i++){
if(i > 9){
if(i % 2 == 0) cout << "even" << endl;
else cout << "odd" << endl;
}
else cout << arr[i] << endl;
}
return 0;
}
----------
====================
----------
CPP.6
easy
----------
PROBLEM STATEMENT:
Functions are a bunch of statements glued together. A function is provided with zero or more arguments, and it executes the statements on it. Based on the return type, it either returns nothing (void) or something.
A sample syntax for a function is
return_type function_name(arg_type_1 arg_1, arg_type_2 arg_2, ...) {
...
...
...
[if return_type is non void]
return something of type `return_type`;
}
For example, a function to read four variables and return the sum of them can be written as
int sum_of_four(int a, int b, int c, int d) {
int sum = 0;
sum += a;
sum += b;
sum += c;
sum += d;
return sum;
}
You have to write a function int max_of_four(int a, int b, int c, int d) which reads four arguments and returns the greatest of them.
+= : Add and assignment operator. It adds the right operand to the left operand and assigns the result to the left operand.
a += b is equivalent to a = a + b;
----------
TOP SOLUTION:
----------
#include <iostream>
#include <cstdio>
using namespace std;
/*
Add `int max_of_four(int a, int b, int c, int d)` here.
*/
int max_of_four(int a, int b, int c, int d){
return max(max(a, b), max(c,d));
}
int main() {
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
int ans = max_of_four(a, b, c, d);
printf("%d", ans);
return 0;
}
----------
====================
----------
CPP.7
easy
----------
PROBLEM STATEMENT:
A pointer in C is a way to share a memory address among different contexts (primarily functions). They are primarily used whenever a function needs to modify the content of a variable, of which it doesn't have ownership.
In order to access the memory address of a variable, [expression].
This memory address is assigned to a pointer and can be shared among various functions. E.g. [expression]).
void increment(int *v) {
(*v)++;
}
int main() {
int a;
scanf("%d", &a);
increment(&a);
printf("%d", a);
return 0;
}
You have to complete the function void update(int *a,int *b), which reads two integers as argument, and sets [expression] with the absolute difference of them.
[expression]
[expression]
----------
TOP SOLUTION:
----------
#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;
void update(int *a,int *b) {
int c = *a;
*a = *a + *b;
*b = fabs(c-*b);
}
int main() {
int a, b;
int *pa = &a, *pb = &b;
scanf("%d %d", &a, &b);
update(pa, pb);
printf("%d\n%d", a, b);
return 0;
}
----------
====================
----------
CPP.8
easy
----------
PROBLEM STATEMENT:
An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.
Declaration:
int arr[10]; //Declares an array named arr of size 10, i.e; you can store 10 integers.
Accessing elements of an array:
Indexing in arrays starts from 0.So the first element is stored at arr[0],the second element at arr[1]...arr[9]
You'll be given an array of [expression] integers and you have to print the integers in the reverse order.
----------
TOP SOLUTION:
----------
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = n - 1; i >= 0; i--)
cout << arr[i] << ' ';
return 0;
}
----------
====================
----------
CPP.9
easy
----------
PROBLEM STATEMENT:
Consider an [expression] varies from array to array). See the Explanation section below for a diagram.
Given [expression] on a new line.
Click here to know more about how to create variable sized arrays in C++.
----------
TOP SOLUTION:
----------
int n, q; cin >> n >> q;
int **v = new int*[n];
for(int j=0;j<n;j++){
int k; cin >> k;
v[j] = new int[k];
for(int i=0;i<k;i++){
int x; cin >> x;
v[j][i] = x;
}
}
for(int i=0;i<q;i++){
int a, b; cin >> a >> b;
cout << v[a][b]<<endl;
}
return 0;
}
----------
====================
----------
CPP.10
medium
----------
PROBLEM STATEMENT:
We have defined our own markup language HRML. In HRML, each element consists of a starting and ending tag, and there are attributes associated with each tag. Only starting tags can have attributes. We can call an attribute by referencing the tag, followed by a tilde, '~' and the name of the attribute. The tags may also be nested.
The opening tags follow the format:
The closing tags follow the format:
For example:
The attributes are referenced as:
tag1~value
tag1.tag2~name
You are given the source code in HRML format consisting of [expression] queries. Each query asks you to print the value of the attribute specified. Print "Not Found!" if there isn't any such attribute.
----------
TOP SOLUTION:
----------
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
vector<string> tag_stack;
map<string, string> attrs;
void insert_attr(string & name, string & val) {
string full;
for(string & str : tag_stack)
full += str + ".";
full.pop_back();
full += "~" + name;
attrs[full] = val;
}
int main() {
int n, q;
cin >> n >> q;
for(int i = 0; i < n; ++i) {
char c; cin >> c;
if(cin.peek() == '/') { // close
string cn; cin >> cn;
tag_stack.pop_back();
}
else { //open'
string name;
cin >> name;
if(name.back() == '>') { //no attrs
name.pop_back();
tag_stack.push_back(name);
}
else {
tag_stack.push_back(name);
for(;;) {
string attr_name, attr_val, eq;
cin >> attr_name >> eq >> attr_val;
if(attr_val.back() == '>') { //last attr
attr_val.pop_back();
attr_val.pop_back();
attr_val = attr_val.substr(1);
insert_attr(attr_name, attr_val);
break;
}
else {
attr_val.pop_back();
attr_val = attr_val.substr(1);
insert_attr(attr_name, attr_val);
}
}
}
}
}
for(int i = 0; i < q; ++i) {
string quer;
cin >> quer;
if(attrs.find(quer) != attrs.end())
cout << attrs[quer] << endl;
else
cout << "Not Found!" << endl;
}
return 0;
}
----------
====================
----------
CPP.11
easy
----------
PROBLEM STATEMENT:
stringstream is a stream class to operate on strings. It basically implements input/output operations on memory (string) based streams. stringstream can be helpful in different type of parsing. The following operators/functions are commonly used here
Operator Extracts formatted data.
Operator Inserts formatted data.
Method str() Gets the contents of underlying string device object.
Method str(string) Sets the contents of underlying string device object.
Its header file is sstream.
One common use of this class is to parse comma-separated integers from a string (e.g., "23,4,56").
stringstream ss("23,4,56");
char ch;
int a, b, c;
ss a ch b ch c; // a = 23, b = 4, c = 56
You have to complete the function vector parseInts(string str). str will be a string consisting of comma-separated integers, and you have to return a vector of int representing the integers.
Note If you want to know how to push elements in a vector, solve the first problem in the STL chapter.
----------
TOP SOLUTION:
----------
#include <bits/stdc++.h>
using namespace std;
vector<int> parseInts(string str) {
stringstream ss(str);
vector<int> result;
char ch;
int tmp;
while(ss >> tmp) {
result.push_back(tmp);
ss >> ch;
}
return result;
}
int main() {
string str;
cin >> str;
vector<int> integers = parseInts(str);
for(int i = 0; i < integers.size(); i++)
cout << integers[i] << "\n";
return 0;
}
----------
====================
----------
CPP.12
easy
----------
PROBLEM STATEMENT:
C++ provides a nice alternative data type to manipulate strings, and the data type is conveniently called string. Some of its widely used features are the following:
Declaration:
string a = "abc";
Size:
int len = a.size();
Concatenate two strings:
string a = "abc";
string b = "def";
string c = a + b; // c = "abcdef".
Accessing [expression] element:
string s = "abc";
char c0 = s[0]; // c0 = 'a'
char c1 = s[1]; // c1 = 'b'
char c2 = s[2]; // c2 = 'c'
s[0] = 'z'; // s = "zbc"
P.S.: We will use cin/cout to read/write a string.
----------
TOP SOLUTION:
----------
#include <iostream>
#include <string>
using namespace std;
int main() {
string a, b;
cin >> a >> b;
cout << a.length() << " " << b.length() << endl;
cout << a << b << endl;
swap(a[0], b[0]);
cout << a << " " << b << endl;
return 0;
}
----------
====================
----------
CPP.13
easy
----------
PROBLEM STATEMENT:
struct is a way to combine multiple fields to represent a composite data structure, which further lays the foundation for Object Oriented Programming. For example, we can store details related to a student in a struct consisting of his age (int), first_name (string), last_name (string) and standard (int).
struct can be represented as
struct NewType {
type1 value1;
type2 value2;
.
.
.
typeN valueN;
};
You have to create a struct, named Student, representing the student's details, as mentioned above, and store the data of a student.
----------
TOP SOLUTION:
----------
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct Student{
int age, standard;
string first_name, last_name;
} st;
int main() {
Student st;
cin >> st.age >> st.first_name >> st.last_name >> st.standard;
cout << st.age << " " << st.first_name << " " << st.last_name << " " << st.standard;
return 0;
}
----------
====================
----------
CPP.14
easy
----------
PROBLEM STATEMENT:
Classes in C++ are user defined types declared with keyword class that has data and functions . Although classes and structures have the same type of functionality, there are some basic differences. The data members of a class are private by default and the members of a structure are public by default. Along with storing multiple data in a common block, it also assigns some functions (known as methods) to manipulate/access them. It serves as the building block of Object Oriented Programming.
It also has access specifiers, which restrict the access of member elements. The primarily used ones are the following:
public: Public members (variables, methods) can be accessed from anywhere the code is visible.
private: Private members can be accessed only by other member functions, and it can not be accessed outside of class.
Class can be represented in the form of
class ClassName {
access_specifier1:
type1 val1;
type2 val2;
ret_type1 method1(type_arg1 arg1, type_arg2 arg2,...)
...
access_specifier2:
type3 val3;
type4 val4;
ret_type2 method2(type_arg3 arg3, type_arg4 arg4,...)
...
};
It's a common practice to make all variables private, and set/get them using public methods. For example:
class SampleClass {
private:
int val;
public:
void set(int a) {
val = a;
}
int get() {
return val;
}
};
We can store details related to a student in a class consisting of his age (int), first_name (string), last_name (string) and standard (int).
You have to create a class, named Student, representing the student's details, as mentioned above, and store the data of a student. Create setter and getter functions for each element; that is, the class should at least have following functions:
get_age, set_age
get_first_name, set_first_name
get_last_name, set_last_name
get_standard, set_standard
Also, you have to create another method to_string() which returns the string consisting of the above elements, separated by a comma(,). You can refer to stringstream for this.
----------
TOP SOLUTION:
----------
#include <iostream>
#include <sstream>
using namespace std;
/*
Enter code for class Student here.
Read statement for specification.
*/
class Student{
public:
int age, standard;
string first_name, last_name;
void set_age(int a){
age = a;
}
void set_first_name(string a){
first_name = a;
}
void set_last_name(string a){
last_name = a;
}
void set_standard(int a){
standard = a;
}
int get_age(){
return age;
}
string get_first_name(){
return first_name;
}
string get_last_name(){
return last_name;
}
int get_standard(){
return standard;
}
string t_string(){
string s = "";
s+=to_string(age);
s+=",";
s+=first_name;
s+=",";
s+=last_name;
s+=",";
s+=to_string(standard);
return s;
}
};
int main() {
int age, standard;
string first_name, last_name;
cin >> age >> first_name >> last_name >> standard;
Student st;
st.set_age(age);
st.set_standard(standard);
st.set_first_name(first_name);
st.set_last_name(last_name);
cout << st.get_age() << "\n";
cout << st.get_last_name() << ", " << st.get_first_name() << "\n";
cout << st.get_standard() << "\n";
cout << "\n";
cout << st.t_string();
return 0;
}
----------
====================
----------
CPP.15
easy
----------
PROBLEM STATEMENT:
A class defines a blueprint for an object. We use the same syntax to declare objects of a class as we use to declare variables of other basic types. For example:
Box box1; // Declares variable box1 of type Box
Box box2; // Declare variable box2 of type Box
Kristen is a contender for valedictorian of her high school. She wants to know how many students (if any) have scored higher than her in the [expression] exams given during this semester.
Create a class named [expression] with the following specifications:
An instance variable named [expression] exam scores.
A void input() function that reads [expression].
An int calculateTotalScore() function that returns the sum of the student's scores.
----------
TOP SOLUTION:
----------
class Student {
int totalScore = 0;
public:
void Input() {
for (int i = 0; i < 5; i++) {
int x;
cin >> x;
totalScore += x;
}
}
int CalculateTotalScore() {
return totalScore;
}
};
----------
====================
----------
CPP.16
easy
----------
PROBLEM STATEMENT:
Design a class named Box whose dimensions are integers and private to the class. The dimensions are labelled: length [expression].
The default constructor of the class should initialize [expression].
The parameterized constructor Box(int length, int breadth, int height) should initialize Box's [expression] to length, breadth and height.
The copy constructor Box[expression], respectively.
Apart from the above, the class should have [expression] functions:
int getLength() - Return box's length
int getBreadth() - Return box's breadth
int getHeight() - Return box's height
long long CalculateVolume() - Return the volume of the box
Overload the operator [expression] if:
[expression]
[expression]
[expression]
Overload operator [expression] for the class Box().
If [expression] is an object of class Box:
[expression] on a single line separated by spaces.
Constraints
[expression]
Two boxes being compared using the [expression] operator will not have all three dimensions equal.
----------
TOP SOLUTION:
----------
class Box {
int l, b, h;
public:
Box() : l(0), b(0), h(0) { BoxesCreated++; }
Box(int length, int breadth, int height) : l(length), b(breadth), h(height) { BoxesCreated++; }
Box(const Box& b) : l(b.l), b(b.b), h(b.h) { BoxesCreated++; }
int getLength() const {
return l;
}
int getBreadth() const {
return b;
}
int getHeight() const {
return h;
}
long long CalculateVolume() const {
return 1LL * l * b * h;
}
~Box() {
BoxesDestroyed++;
}
bool operator<(const Box& another) const {
if (l != another.l) {
return l < another.l;