Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc9f371

Browse files
committed
added templates
1 parent 38225e4 commit fc9f371

File tree

25 files changed

+752
-0
lines changed

25 files changed

+752
-0
lines changed

cpp/sprint2/B/code.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "solution.h"
2+
3+
/*
4+
Comment it before submitting
5+
struct Node {
6+
std::string value;
7+
Node* next;
8+
Node(const std::string &value, Node* next);
9+
};
10+
*/
11+
12+
void solution(Node* head) {
13+
// Your code
14+
// ヽ(´▽`)/
15+
}
16+
17+
void test() {
18+
Node node3("node3", nullptr);
19+
Node node2("node2", &node3);
20+
Node node1("node1", &node2);
21+
Node node0("node0", &node1);
22+
solution(&node0);
23+
/*
24+
Output is:
25+
node0
26+
node1
27+
node2
28+
node3
29+
*/
30+
}

cpp/sprint2/C/code.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "solution.h"
2+
3+
4+
5+
/*
6+
Comment it before submitting
7+
struct Node {
8+
std::string value;
9+
Node* next;
10+
Node(const std::string &value, Node* next);
11+
};
12+
*/
13+
14+
Node* solution(Node* head, int idx) {
15+
// Your code
16+
// ヽ(´▽`)/
17+
}
18+
19+
void test() {
20+
Node node3("node3", nullptr);
21+
Node node2("node2", &node3);
22+
Node node1("node1", &node2);
23+
Node node0("node0", &node1);
24+
Node* new_head = solution(&node0, 1);
25+
// result is : node0 -> node2 -> node3
26+
}

cpp/sprint2/D/code.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "solution.h"
2+
3+
/*
4+
Comment it before submitting
5+
struct Node {
6+
std::string value;
7+
Node* next;
8+
Node(const std::string &value, Node* next);
9+
};
10+
*/
11+
12+
int solution(Node* head, const std::string& elem) {
13+
// Your code
14+
// ヽ(´▽`)/
15+
}
16+
17+
void test() {
18+
Node node3("node3", nullptr);
19+
Node node2("node2", &node3);
20+
Node node1("node1", &node2);
21+
Node node0("node0", &node1);
22+
int idx = solution(&node0, "node2");
23+
// result is : idx == 2
24+
}

cpp/sprint2/E/code.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "solution.h"
2+
3+
// Comment it before submitting
4+
// struct Node {
5+
// Node(const std::string &value, Node* next, Node* prev)
6+
// : value(value)
7+
// , next(next)
8+
// , prev(prev)
9+
// {}
10+
// std::string value;
11+
// Node* next;
12+
// Node* prev;
13+
// };
14+
15+
Node* solution(Node* head) {
16+
// Your code
17+
// ヽ(´▽`)/
18+
}
19+
20+
void test() {
21+
Node node3("node3", nullptr, nullptr);
22+
Node node2("node2", nullptr, nullptr);
23+
Node node1("node1", nullptr, nullptr);
24+
Node node0("node0", nullptr, nullptr);
25+
node0.next = &node1;
26+
27+
node1.next = &node2;
28+
node1.prev = &node0;
29+
30+
node2.next = &node3;
31+
node2.prev = &node1;
32+
33+
node3.prev = &node2;
34+
Node* new_head = solution(&node0);
35+
// result is : new_head == node3
36+
// node3->next == node2
37+
// node2->next == node1
38+
// node2->prev == node3
39+
// node1->next == node0
40+
// node1->prev == node2
41+
// node0->prev == node1
42+
}

csharp/sprint2/B/Solution.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
// закомментируйте перед отправкой
3+
4+
public class Node<TValue>
5+
{
6+
public TValue Value { get; private set; }
7+
public Node<TValue> Next { get; set; }
8+
9+
public Node(TValue value, Node<TValue> next)
10+
{
11+
Value = value;
12+
Next = next;
13+
}
14+
}
15+
*/
16+
17+
public class Solution<TValue>
18+
{
19+
public static void Solve(Node<TValue> head)
20+
{
21+
// Your code
22+
// ヽ(´▽`)/
23+
}
24+
25+
private static void Test()
26+
{
27+
var node3 = new Node<string>("node3", null);
28+
var node2 = new Node<string>("node2", node3);
29+
var node1 = new Node<string>("node1", node2);
30+
var node0 = new Node<string>("node0", node1);
31+
Solve(node0);
32+
/*
33+
Output is:
34+
node0
35+
node1
36+
node2
37+
node3
38+
*/
39+
}
40+
}

csharp/sprint2/C/Solution.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
// закомментируйте перед отправкой
3+
4+
public class Node<TValue>
5+
{
6+
public TValue Value { get; private set; }
7+
public Node<TValue> Next { get; set; }
8+
9+
public Node(TValue value, Node<TValue> next)
10+
{
11+
Value = value;
12+
Next = next;
13+
}
14+
}
15+
*/
16+
17+
public class Solution<TValue>
18+
{
19+
public static Node<TValue> Solve(Node<TValue> head, int idx)
20+
{
21+
// Your code
22+
// ヽ(´▽`)/
23+
}
24+
25+
private static void Test()
26+
{
27+
var node3 = new Node<string>("node3", null);
28+
var node2 = new Node<string>("node2", node3);
29+
var node1 = new Node<string>("node1", node2);
30+
var node0 = new Node<string>("node0", node1);
31+
var newHead = Solve(node0, 1);
32+
// result is : node0 -> node2 -> node3
33+
}
34+
}

csharp/sprint2/D/Solution.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
// закомментируйте перед отправкой
3+
4+
public class Node<TValue>
5+
{
6+
public TValue Value { get; private set; }
7+
public Node<TValue> Next { get; set; }
8+
9+
public Node(TValue value, Node<TValue> next)
10+
{
11+
Value = value;
12+
Next = next;
13+
}
14+
}
15+
*/
16+
17+
public class Solution
18+
{
19+
public static int Solve(Node<string> head, string item)
20+
{
21+
// Your code
22+
// ヽ(´▽`)/
23+
}
24+
25+
private static void Test()
26+
{
27+
var node3 = new Node<string>("node3", null);
28+
var node2 = new Node<string>("node2", node3);
29+
var node1 = new Node<string>("node1", node2);
30+
var node0 = new Node<string>("node0", node1);
31+
var idx = Solve(node0, "node0");
32+
// result is : idx == 2
33+
}
34+
}
35+

csharp/sprint2/E/Solution.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
3+
// закомментируйте перед отправкой
4+
5+
public class Node<TValue>
6+
{
7+
public TValue Value { get; private set; }
8+
public Node<TValue> Next { get; set; }
9+
public Node<TValue> Prev { get; set; }
10+
11+
public Node(TValue value, Node<TValue> next, Node<TValue> prev)
12+
{
13+
Value = value;
14+
Next = next;
15+
Prev = prev;
16+
}
17+
}
18+
19+
*/
20+
21+
public class Solution
22+
{
23+
public static Node<string> Solve(Node<string> head)
24+
{
25+
// Your code
26+
// ヽ(´▽`)/
27+
}
28+
29+
private static void Test()
30+
{
31+
var node3 = new Node<string>("node3", null, null);
32+
var node2 = new Node<string>("node2", node3, null);
33+
var node1 = new Node<string>("node1", node2, null);
34+
var node0 = new Node<string>("node0", node1, null);
35+
var newNode = Solve(node0);
36+
/*
37+
result is : newNode == node3
38+
node3.next == node2
39+
node2.next == node1
40+
node2.prev == node3
41+
node1.next == node0
42+
node1.prev == node2
43+
node0.prev == node1
44+
*/
45+
}
46+
}

go/sprint2/B/code.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
/*
4+
Comment it before submitting
5+
type ListNode struct {
6+
data string
7+
next *ListNode
8+
}
9+
*/
10+
11+
func Solution (head *ListNode) {
12+
// Your code
13+
// ヽ(´▽`)/
14+
}
15+
16+
func test() {
17+
node3 := ListNode{"node3", nil}
18+
node2 := ListNode{"node2", &node3}
19+
node1 := ListNode{"node1", &node2}
20+
node0 := ListNode{"node0", &node1}
21+
Solution(&node0)
22+
/*
23+
Output is:
24+
node0
25+
node1
26+
node2
27+
node3
28+
*/
29+
}

go/sprint2/C/code.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
/*
4+
Comment it before submitting
5+
type ListNode struct {
6+
data string
7+
next *ListNode
8+
}
9+
*/
10+
11+
func Solution (head *ListNode, idx int) *ListNode {
12+
// Your code
13+
// ヽ(´▽`)/
14+
}
15+
16+
func test() {
17+
node3 := ListNode{"node3", nil}
18+
node2 := ListNode{"node2", &node3}
19+
node1 := ListNode{"node1", &node2}
20+
node0 := ListNode{"node0", &node1}
21+
/*newHead :=*/ Solution(&node0, 1)
22+
// result is : node0 -> node2 -> node3
23+
}

go/sprint2/D/code.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
/*
4+
Comment it before submitting
5+
type ListNode struct {
6+
data string
7+
next *ListNode
8+
}
9+
*/
10+
11+
func Solution (head *ListNode, elem string) int {
12+
// Your code
13+
// ヽ(´▽`)/
14+
}
15+
16+
func test() {
17+
node3 := ListNode{"node3", nil}
18+
node2 := ListNode{"node2", &node3}
19+
node1 := ListNode{"node1", &node2}
20+
node0 := ListNode{"node0", &node1}
21+
/*idx :=*/ Solution(&node0, "node2")
22+
// result is : idx == 2
23+
}

0 commit comments

Comments
 (0)