Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
91932e2
Create 2_problem.txt
jerald-jacob Oct 10, 2022
56c52a1
Merge pull request #56 from Marian-MCA/jerald-jacob-patch-8
jerald-jacob Oct 12, 2022
bc6a76a
Merge pull request #55 from Marian-MCA/jerald-jacob-patch-7
jerald-jacob Oct 12, 2022
18a6d0b
Update 2_problem.txt
jerald-jacob Oct 12, 2022
4df48a3
Update 2_problem.txt
jerald-jacob Oct 12, 2022
aca9baf
add question & answer to Basic-Part-2
Kavishcan Oct 12, 2022
adc070f
Create 3_problem.md
ajilraju Oct 13, 2022
4536ccc
Merge pull request #59 from ajilraju/master
ajilraju Oct 13, 2022
6159529
Merge pull request #57 from Marian-MCA/jerald-jacob-patch-9
ajilraju Oct 13, 2022
5b21878
Merge pull request #58 from Kavishcan/master
ajilraju Oct 13, 2022
bf41bd9
Create 4_problem.md
ajilraju Oct 14, 2022
c21bab8
4_solution.go added
ajilraju Oct 14, 2022
ba1cadb
Merge pull request #60 from ajilraju/master
ajilraju Oct 14, 2022
f898791
Create 5_problem.md
ajilraju Oct 18, 2022
5a5836b
Create 5_solution.go
ajilraju Oct 18, 2022
e72bd24
Merge pull request #61 from ajilraju/master
ajilraju Oct 18, 2022
3dc1af1
Add lottery system code.
PansiluAW Oct 24, 2022
471ac29
problem 6 is added
ajilraju Oct 26, 2022
cb404a1
Merge pull request #63 from jomoljoz/jomol
ajilraju Oct 26, 2022
e42d68e
prolem number 7 is added
ajilraju Oct 26, 2022
19b50f7
Merge pull request #64 from jomoljoz/jomol
ajilraju Oct 26, 2022
cb52338
Create 3_solution.py
1-Rishabh-Jain-1 Oct 26, 2022
68e503b
problem 8 is added
ajilraju Oct 27, 2022
153c1f7
Merge pull request #66 from jomoljoz/jomol
ajilraju Oct 27, 2022
28202e8
problem 9 is added
ajilraju Oct 27, 2022
40a72dd
Merge pull request #67 from jomoljoz/jomol
ajilraju Oct 27, 2022
262be93
Create 10_problem
jerald-jacob Oct 10, 2023
457e3d9
Merge pull request #68 from Marian-MCA/jerald-jacob-patch-10
jerald-jacob Oct 10, 2023
c62a7a2
Create 10_solution
jerald-jacob Oct 10, 2023
0d6c3c0
Merge pull request #69 from Marian-MCA/jerald-jacob-patch-11
jerald-jacob Oct 10, 2023
63ad1f7
Merge pull request #65 from 1-Rishabh-Jain-1/patch-1
jerald-jacob Oct 17, 2023
ef7a594
Merge pull request #62 from PansiluAW/master
jerald-jacob Oct 17, 2023
8169f1d
Create Ai
jerald-jacob Oct 17, 2023
a84cf1e
Merge pull request #70 from Marian-MCA/dev
jerald-jacob Oct 17, 2023
11a8415
Create Ans
jerald-jacob Oct 17, 2023
8acaee8
Merge pull request #71 from Marian-MCA/dev
jerald-jacob Oct 17, 2023
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
1 change: 1 addition & 0 deletions Ai
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
What is Generative AI on AWS?
1 change: 1 addition & 0 deletions Ans
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
From startups to enterprises, organizations trust AWS to innovate with generative artificial intelligence (AI). With enterprise-grade security and privacy, access to industry-leading foundation models, and generative AI-powered applications, AWS makes it easy to build and scale generative AI, built for your data, your use cases and your customers.
1 change: 1 addition & 0 deletions archives/Basic-Part-2/questions/qn_30.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Write a Python program to count the numbers divisible by 7 or 11 in a given array of integers using Lambda.
5 changes: 5 additions & 0 deletions archives/Basic-Part-2/source-code/qn_30_ans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
array_nums = [1, 7, 22, 23, 28, 38, 45, 56]
print("Original arrays:")
print(array_nums)
nums = len(list(filter(lambda x: (x%7 == 0 or x%11 == 0) , array_nums)))
print("\nNumber of numbers divisible by 7 or 11 in the above array: ", nums)
1 change: 1 addition & 0 deletions problems/10_problem
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
What is forkjoin ?
6 changes: 6 additions & 0 deletions problems/2_problem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Write a Python program that iterate over elements repeating each as many times as its count.

Note: Elements are returned in arbitrary order.

Sample Output: ['p', 'p', 'p', 'p', 'q', 'q']

5 changes: 5 additions & 0 deletions problems/3_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Given an integer x, return true if x is palindrome integer.

An integer is a palindrome when it reads the same backward as forward.

For example, 121 is a palindrome while 123 is not.
22 changes: 22 additions & 0 deletions problems/4_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.

Given a string s, return true if it is a palindrome, or false otherwise.



Example 1:

Input: s = "A man, a plan, a canal: Panama"
Output: true
Explanation: "amanaplanacanalpanama" is a palindrome.
Example 2:

Input: s = "race a car"
Output: false
Explanation: "raceacar" is not a palindrome.
Example 3:

Input: s = " "
Output: true
Explanation: s is an empty string "" after removing non-alphanumeric characters.
Since an empty string reads the same forward and backward, it is a palindrome.
5 changes: 5 additions & 0 deletions problems/5_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Given an integer x, return true if x is palindrome integer.

An integer is a palindrome when it reads the same backward as forward.

For example, 121 is a palindrome while 123 is not.
14 changes: 14 additions & 0 deletions problems/6_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function).

The algorithm for myAtoi(string s) is as follows:

Read in and ignore any leading whitespace.
Check if the next character (if not already at the end of the string) is '-' or '+'. Read this character in if it is either. This determines if the final result is negative or positive respectively. Assume the result is positive if neither is present.
Read in next the characters until the next non-digit character or the end of the input is reached. The rest of the string is ignored.
Convert these digits into an integer (i.e. "123" -> 123, "0032" -> 32). If no digits were read, then the integer is 0. Change the sign as necessary (from step 2).
If the integer is out of the 32-bit signed integer range [-231, 231 - 1], then clamp the integer so that it remains in the range. Specifically, integers less than -231 should be clamped to -231, and integers greater than 231 - 1 should be clamped to 231 - 1.
Return the integer as the final result.
Note:

Only the space character ' ' is considered a whitespace character.
Do not ignore any characters other than the leading whitespace or the rest of the string after the digits.
21 changes: 21 additions & 0 deletions problems/7_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Given a string s consisting of words and spaces, return the length of the last word in the string.

A word is a maximal substring consisting of non-space characters only.



Example 1:

Input: s = "Hello World"
Output: 5
Explanation: The last word is "World" with length 5.
Example 2:

Input: s = " fly me to the moon "
Output: 4
Explanation: The last word is "moon" with length 4.
Example 3:

Input: s = "luffy is still joyboy"
Output: 6
Explanation: The last word is "joyboy" with length 6.
12 changes: 12 additions & 0 deletions problems/8_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Given two binary strings a and b, return their sum as a binary string.



Example 1:

Input: a = "11", b = "1"
Output: "100"
Example 2:

Input: a = "1010", b = "1011"
Output: "10101"
27 changes: 27 additions & 0 deletions problems/9_problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.

For example:

A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...


Example 1:

Input: columnNumber = 1
Output: "A"
Example 2:

Input: columnNumber = 28
Output: "AB"
Example 3:

Input: columnNumber = 701
Output: "ZY"

22 changes: 22 additions & 0 deletions problems/ProjectLotteryProblem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Lottery system, where the user can input 5 numbers of choice and the system will generate another set of 5 numbers. The program will then check if the entered numbers have any match with the numbers generated randomly by the system and giveout the number of matches in the set of input numbers by the user.

If there is no match, te system will display matches as 0(zero).

Example 1:

User input numbers : 1, 2, 3, 5, 4

Lottery numbers generated randomly by system : 30, 19, 21, 3, 32

Output : You have 0 matches

Example 2:

User input number : 45, 34, 65, 34, 22

Lottery numbers generated randomly by system : 5, 34, 40, 16, 37

You have 1 matches



102 changes: 102 additions & 0 deletions solutions/10_solution
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
Fork/Join
The fork/join framework is an implementation of the ExecutorService interface that helps you take advantage of multiple processors. It is designed for work that can be broken into smaller pieces recursively. The goal is to use all the available processing power to enhance the performance of your application.

As with any ExecutorService implementation, the fork/join framework distributes tasks to worker threads in a thread pool. The fork/join framework is distinct because it uses a work-stealing algorithm. Worker threads that run out of things to do can steal tasks from other threads that are still busy.

The center of the fork/join framework is the ForkJoinPool class, an extension of the AbstractExecutorService class. ForkJoinPool implements the core work-stealing algorithm and can execute ForkJoinTask processes.

Basic Use
The first step for using the fork/join framework is to write code that performs a segment of the work. Your code should look similar to the following pseudocode:

if (my portion of the work is small enough)
do the work directly
else
split my work into two pieces
invoke the two pieces and wait for the results
Wrap this code in a ForkJoinTask subclass, typically using one of its more specialized types, either RecursiveTask (which can return a result) or RecursiveAction.

After your ForkJoinTask subclass is ready, create the object that represents all the work to be done and pass it to the invoke() method of a ForkJoinPool instance.

Blurring for Clarity
To help you understand how the fork/join framework works, consider the following example. Suppose that you want to blur an image. The original source image is represented by an array of integers, where each integer contains the color values for a single pixel. The blurred destination image is also represented by an integer array with the same size as the source.

Performing the blur is accomplished by working through the source array one pixel at a time. Each pixel is averaged with its surrounding pixels (the red, green, and blue components are averaged), and the result is placed in the destination array. Since an image is a large array, this process can take a long time. You can take advantage of concurrent processing on multiprocessor systems by implementing the algorithm using the fork/join framework. Here is one possible implementation:

public class ForkBlur extends RecursiveAction {
private int[] mSource;
private int mStart;
private int mLength;
private int[] mDestination;

// Processing window size; should be odd.
private int mBlurWidth = 15;

public ForkBlur(int[] src, int start, int length, int[] dst) {
mSource = src;
mStart = start;
mLength = length;
mDestination = dst;
}

protected void computeDirectly() {
int sidePixels = (mBlurWidth - 1) / 2;
for (int index = mStart; index < mStart + mLength; index++) {
// Calculate average.
float rt = 0, gt = 0, bt = 0;
for (int mi = -sidePixels; mi <= sidePixels; mi++) {
int mindex = Math.min(Math.max(mi + index, 0),
mSource.length - 1);
int pixel = mSource[mindex];
rt += (float)((pixel & 0x00ff0000) >> 16)
/ mBlurWidth;
gt += (float)((pixel & 0x0000ff00) >> 8)
/ mBlurWidth;
bt += (float)((pixel & 0x000000ff) >> 0)
/ mBlurWidth;
}

// Reassemble destination pixel.
int dpixel = (0xff000000 ) |
(((int)rt) << 16) |
(((int)gt) << 8) |
(((int)bt) << 0);
mDestination[index] = dpixel;
}
}

...
Now you implement the abstract compute() method, which either performs the blur directly or splits it into two smaller tasks. A simple array length threshold helps determine whether the work is performed or split.

protected static int sThreshold = 100000;

protected void compute() {
if (mLength < sThreshold) {
computeDirectly();
return;
}

int split = mLength / 2;

invokeAll(new ForkBlur(mSource, mStart, split, mDestination),
new ForkBlur(mSource, mStart + split, mLength - split,
mDestination));
}
If the previous methods are in a subclass of the RecursiveAction class, then setting up the task to run in a ForkJoinPool is straightforward, and involves the following steps:

Create a task that represents all of the work to be done.

// source image pixels are in src
// destination image pixels are in dst
ForkBlur fb = new ForkBlur(src, 0, src.length, dst);
Create the ForkJoinPool that will run the task.

ForkJoinPool pool = new ForkJoinPool();
Run the task.

pool.invoke(fb);
For the full source code, including some extra code that creates the destination image file, see the ForkBlur example.

Standard Implementations
Besides using the fork/join framework to implement custom algorithms for tasks to be performed concurrently on a multiprocessor system (such as the ForkBlur.java example in the previous section), there are some generally useful features in Java SE which are already implemented using the fork/join framework. One such implementation, introduced in Java SE 8, is used by the java.util.Arrays class for its parallelSort() methods. These methods are similar to sort(), but leverage concurrency via the fork/join framework. Parallel sorting of large arrays is faster than sequential sorting when run on multiprocessor systems. However, how exactly the fork/join framework is leveraged by these methods is outside the scope of the Java Tutorials. For this information, see the Java API documentation.

Another implementation of the fork/join framework is used by methods in the java.util.streams package, which is part of Project Lambda scheduled for the Java SE 8 release. For more information, see the Lambda Expressions section.
18 changes: 18 additions & 0 deletions solutions/3_solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def check_palindrome(n):
temp = n
rev = 0
is_palindrome = False
while (n != 0):
digit = n % 10
rev = rev * 10 + digit
n = n // 10
if temp == rev:
is_palindrome = True
return is_palindrome

n = int(input("Enter any number: "))
ans = check_palindrome(n)
if ans == True:
print("The given number is a palindrome!")
else:
print("The given number is not a palindrome!")
42 changes: 42 additions & 0 deletions solutions/4_solution.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// https://leetcode.com/problems/valid-palindrome/

package main

import (
"fmt"
"strings"
"unicode"
)

func isIgnoreCase(s rune) bool {
if unicode.IsLetter(s) || unicode.IsDigit(s) {
return false
}
return true
}
func isPalindrome(s string) bool {

valid_string := ""
for _, str := range s {
if !isIgnoreCase(rune(str)) {
valid_string += string(str)
}
}

tempStr := strings.ToLower(valid_string)
dummyString := ""

for i := len(tempStr) - 1; i >= 0; i-- {
dummyString += string(tempStr[i])
}

return strings.ToLower(valid_string) == string(dummyString)
}

func main() {
testString := []string{"A man, a plan, a canal: Panama", "race a car", "mala:y:alam", " ", "0P"}

for _, s := range testString {
fmt.Println(isPalindrome(s))
}
}
16 changes: 16 additions & 0 deletions solutions/5_solution.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
func isPalindrome(x int) bool {
temp := x
sum := 0
rem := 0

for x > 0 {
rem = x % 10
sum = (sum * 10) + rem
x /= 10
}

if sum == temp {
return true
}
return false
}
44 changes: 44 additions & 0 deletions solutions/ProjectLotterySolution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#IMPORT RANDOM MODULE
import random

#CREATE VARIABLE
user_list = []
random_list = []
user_value = 0
random_value = 0
count = 0
matches = 0

#GET VALUES FROM THE USER INTO A LIST
user_list.append(int(input("Insert number 1 : ")))
user_list.append(int(input("Insert number 2 : ")))
user_list.append(int(input("Insert number 3 : ")))
user_list.append(int(input("Insert number 4 : ")))
user_list.append(int(input("Insert number 5 : ")))
print("\n")

#GET RANDOM NUMBERS INTO A LIST
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))
random_list.append(random.randrange(1,50))

#DISPLAY THE USER ENTRIES
print("User number :",end = " ")
for user_value in user_list:
print(user_value,end = " ")
print("\n")

#DISPLAY THE LOTTERY NUMBERS
print("Lottery numbers : ",end = " ")
for random_value in random_list:
print(random_value,end = " " )

#LOOK FOR MATCHING VALUES IN BOTH LISTS
for count in range (5):
if user_list[count] == random_list[count]:
matches +=1

#DISPLAY NUMBER OF MATCHES
print("\n\nYou have",matches,"matches")