Logical Problems
Logical Problems
Here sets are divided by 5, first set prints numbers where next set prints * so on and so
forth
If n=12, output: 1 2 3 4 5 * * * * * 11 12
If n=4, output: 1 2 3 4
8. Generate a dictionary which stores the count of appearance of character in string
Input: aabbcdddededfg
Output= {“a”: 2, “b”: 2, “c”: 1, “d”:5, “e”:2, “f”:1, “g”:1}
9. Given a string of 0s and 1s print the value of string, where val(0)=1, val(1)=2
Input: 00010110
Output: 11
12.Write a function that generates the first n numbers of the Fibonacci sequence. The
Fibonacci sequence is a series of numbers where each number is the sum of the two
preceding ones, usually starting with 0 and 1. For example, the first 10 numbers in the
Fibonacci sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34.
13.This week's exercise is to write a function that performs a matrix transposition. Matrix
transposition means swapping the rows and columns of a matrix. For example, if you
have a 2x3 matrix:
123
456
14
25
36
14.Write a function that implements the binary search algorithm using iteration.
15.Write a function to solve the Two Sum problem, a popular interview question. Given an
array of integers and a target sum, return the indices of the two numbers that add up to
the target. For example, given the array [2, 7, 11, 15] and the target sum 9, the function
should return [0, 1] because 2 + 7 = 9.
17.Valid Parentheses :
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input
string is valid.
Example 2:
Input: s = "()[]{}"
Output: true
Example 3:
Input: s = "(]"
Output: false
Example 4:
Input: s = "([])"
Output: true
54321
DCBA
321
BA
1
19.
Make sure to solve all problems without copying any code from
anywhere. Note that understanding how to solve a problem is more
important than completing it by copying from somewhere.
Refer following repo and upload your solution on github/gitlab just like this:
https://github.com/RohitPatil18/Data-Structure-Algorithm-Practice/tree/main/Recursion