Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated functions and arrays #35

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions build-logic/002_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@
**Example:**
**Input:** `typeOfTriangle(30, 60, 90)` ––> **Output:** `Scalene Triangle`

1. Given an object `obj`, write a function to invert its `key` and `value` for each entries. Inversion will result in value being used as key and key as value.
**Note:- There will be no repeated values to maintain the uniqueness.**
**Example:**
```javascript
// Input:
obj = {
"name" : "John",
"age" : 51,
"hairColor" : "black",
"eyes" : "round"
}

// Output:
obj = {
"John" : "name",
"51" : "age",
"black" : "hairColor",
"round" : "eyes"
}
```
## Medium

1. Given an array, your function should return the length of the array.
Expand Down
9 changes: 9 additions & 0 deletions build-logic/004_strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@
1. Write a program to toggle case of each character of the string "good afternoon" (example: "neogcamp" ⇒ "nEoGcAmP" )

1. Given a string "how was your day?" and a word "how", write a program that removes the occurrence of the specified word from given sentence. ( input: string⇒"programming camp are amazing",word⇒ "programming"; output:" camp are amazing")

1. Given a string `s`, find the first non-repeating character in it and return its index If it does not exist, return `-1`
```javascript
Input: s = "neogcamp"
Output: 0

Input: s = "nneeooggccaammpp"
Output: -1
```
36 changes: 34 additions & 2 deletions build-logic/005_arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,41 @@
6. Find number of constants and vowels in a string.
7. Shift an array by X to right.
- Example [1,2,3,4,5] after shifting to right [5,1,2,3,4]
8. Given an array of numbers, pick any two numbers `a` and `b`, we could get the difference by `Math.abs(a - b)` . Write a function to get the largest difference in the array.

9. Given an array and size k, break the array into chunks of k-length and return them as an array.
```javascript
Input: arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k = 3
Output: [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]
```
10. Given an array `nums` with length `n` , return the element which occurred at least `n/2` times in the array.
```javascript
Input: nums = [2,2,1,1,1,2,2]
Output: 2
```

## Advanced

1. Find the sum of two matrix.
1. Display transpose of matrix. Explaination https://www.varsitytutors.com/linear_algebra-help/the-transpose
1. Find Identity matrix. Explanation https://www.varsitytutors.com/hotmath/hotmath_help/topics/identity-matrix
2. Display transpose of matrix. Explaination https://www.varsitytutors.com/linear_algebra-help/the-transpose
3. Find Identity matrix. Explanation https://www.varsitytutors.com/hotmath/hotmath_help/topics/identity-matrix

4. Given an array `arr` with different counts of number we have to find the number with most frequency and return it.
If there are two or more numbers with same most frequency the return the biggest number.
1. Given an array of integers `nums` and an integer `target`, check if there are two numbers in the array such that they add up to target . Return any one pair that add up to `target`
```javascript
Input: nums = [3,7,11,15], target = 18
Output: [3,15]
Explanation : nus[0] + nums[3] = 18
```
1. Given an array `arr` with different counts of number we have to find the number with least frequency and return it.
If there are two or more numbers with same least frequency the return the biggest number.
```javascript
Input: arr = [2, 2, 2, 3, 3, 3, 4, 4, 4, 2, 5, 5, 5, 6, 6]
Output: 6
```
1. Given an integer array `nums`, move all `0's` to the end of it while maintaining the relative order of the non-zero elements.
```javascript
Input: nums = [0,2,0,3,12,0]
Output: [2,3,12,0,0,0]
```