HackerRank Notes
HackerRank Notes
53214
Now, If the next key comes as 1(which is a cache hit),
then the cache state in the same order will be -
15324
Now, If the next key comes as 6(which is a cache miss),
then the cache state in the same order will be -
61532
You can observe that 4 has been discarded because it
was the least recently used key and since the capacity of
cache is 5, it could not be retained in the cache any
longer.
Declaration:
string a = "abc";
Size:
string s = "abc";
char c0 = s[0]; // c0 = 'a'
char c1 = s[1]; // c1 = 'b'
char c2 = s[2]; // c2 = 'c'
struct NewType {
type1 value1;
type2 value2;
.
.
.
typeN valueN;
};
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).
GCC is one of the most common choices for compiling C and C++
programs on Unix-based systems. If you're developing for Linux, GCC
is a good go-to choice. It can also be used for Windows, but other
compilers are typically preferred, such as the compiler included
with Microsoft Visual Studio.