10 Beginner Dsa Questions Syntax Error Full
10 Beginner Dsa Questions Syntax Error Full
[C++ Code]
return maxVal;
[Java Code]
return maxVal;
[Python Code]
def find_max(arr):
max_val = arr[0]
max_val = num
return max_val
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
[C++ Code]
bool isPrime(int n) {
if (n % i == 0) return false;
return true;
[Java Code]
boolean isPrime(int n) {
if (n % i == 0) return false;
return true;
[Python Code]
def is_prime(n):
if n <= 1:
return False
if n % i == 0:
return False
return True
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
3. Reverse an Array
[C++ Code]
swap(arr[start], arr[end]);
start++;
end--;
[Java Code]
arr[start++] = arr[end];
arr[end--] = temp;
[Python Code]
def reverse_array(arr):
start += 1
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
end -= 1
[C++ Code]
bool isPalindrome(string s) {
return true;
[Java Code]
boolean isPalindrome(String s) {
return true;
[Python Code]
def is_palindrome(s):
return s == s[::-1]
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
[C++ Code]
#include <unordered_map>
[Java Code]
[Python Code]
def count_frequency(arr):
return Counter(arr)
[C++ Code]
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
return false;
[Java Code]
return false;
[Python Code]
if num == x:
return True
return False
[C++ Code]
int sum = 0;
return sum;
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
[Java Code]
int sum = 0;
return sum;
[Python Code]
def array_sum(arr):
return sum(arr)
8. Factorial of a Number
[C++ Code]
int factorial(int n) {
int result = 1;
return result;
[Java Code]
int factorial(int n) {
int result = 1;
return result;
[Python Code]
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
def factorial(n):
result = 1
result *= i
return result
[C++ Code]
void fibonacci(int n) {
int a = 0, b = 1;
int next = a + b;
a = b;
b = next;
[Java Code]
void fibonacci(int n) {
int a = 0, b = 1;
int next = a + b;
a = b;
b = next;
By SYNTAX ERROR
10 Beginner-Friendly DSA Questions to Kickstart Your Journey
[Python Code]
def fibonacci(n):
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
By SYNTAX ERROR