0% found this document useful (0 votes)
106 views

Aug Last Week Coding Questions Accenture

acc coding aug

Uploaded by

Aum Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

Aug Last Week Coding Questions Accenture

acc coding aug

Uploaded by

Aum Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

CODING

QUESTIONS

2025
youtube.com/@teknouf
UBK ANNA
UF
O
KN
TE

12,24,35,9
8
3
0
4

2025
youtube.com/@teknouf
UBK ANNA
public class Main {
public static int findIndexOfDividend(int[] arr, int divisor, int
remainder, int quotient) {
for (int i = 0; i < arr.length; i++) {
if (arr[i] / divisor == quotient && arr[i] % divisor ==

UF
remainder) {
return i; // 12/8=3,24%8==0,2,21 // 1
}
}
return -1;
}

public static void main(String[] args) {


O
int[] arr = {12, 4, 24, 21};
int divisor = 8;
int remainder = 0;
int quotient = 3;
KN

int index = findIndexOfDividend(arr, divisor, remainder,


quotient);

System.out.println(index);
}
}
TE

2025
youtube.com/@teknouf
UBK ANNA
def find_index_of_dividend(arr, divisor, remainder, quotient):
for index, dividend in enumerate(arr):
if dividend // divisor == quotient and dividend % divisor ==
remainder:
return index
return -1

UF
arr = [12, 2, 2, 21]
divisor = 8
remainder = 0
quotient = 3

index = find_index_of_dividend(arr, divisor, remainder, quotient)


O
print(index)
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
UF
O
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
Input: `S = "HTHHTTHTHHHT"`
- Output:`Score = 10`

Explanation:
- H (Score: 2)
- T (Score: 1)
- H (Score: 3)

UF
- H (Score: 5)
- T (Score: 4)
- T (Score: 3)
- H (Score: 5)
- T (Score: 4)
- H (Score: 6)
- H (Score: 8)
- H (Score: 10) → Stop here (3 consecutive heads), final score = 10
O
Example 2:

- Input:S = "TTTHHTT"`
KN

- Output:Score = -1`

Explanation:
- T (Score: -1)
- T (Score: -2)
- T (Score: -3)
- H (Score: -1)
TE

- H (Score: 1)
- T (Score: 0)
- T (Score: -1) → Entire string processed, final score = -1

2025
youtube.com/@teknouf
UBK ANNA
public class Main {

public static int tossAndScore(String S) {


int score = 0;
int countHeads = 0;

UF
for (int i = 0; i < S.length(); i++) {//HTHHTTHTHHHT
char toss = S.charAt(i); // H

if (toss == 'H') {
score += 2;// 10
countHeads += 1; // 3
} else {
score -= 1; // 1
O
countHeads = 0;
}
KN

if (countHeads == 3) {
break;
}
}

return score;
}
TE

public static void main(String[] args) {


//System.out.println(tossAndScore("HTHHTTHTHHHT"));
System.out.println(tossAndScore("TTTHHTT"));
}
}

2025
youtube.com/@teknouf
UBK ANNA
def toss_and_score(S):
score = 0
count_heads = 0

for toss in S: # HTHHTTHTHHHT

UF
if toss == 'H':
score += 2
count_heads += 1
else:
score -= 1
count_heads = 0

if count_heads == 3:
O
break

return score
KN

print(toss_and_score("HTHHTTHTHHHT"))
#print(toss_and_score("TTTHHTT"))
TE

2025
youtube.com/@teknouf
UBK ANNA
UF
O
KN

OUTPUT: 17
TE

2025
youtube.com/@teknouf
UBK ANNA
array1 = [1, 2, 3]
array2 = [4, 2, 3]

result = []
for i in range(len(array1)):
result.append(array1[i] * array2[i])

UF
total_sum = 0
for value in result:
total_sum += value

print(total_sum)
O
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
public class Main {
public static void main(String[] args) {
int[] array1 = {1, 2, 3};
int[] array2 = {4, 2, 3};

if (array1.length != array2.length) {

UF
System.out.println("Arrays must be of the same length.");
return;
}

int totalSum = 0;
for (int i = 0; i < array1.length; i++) {
int product = array1[i] * array2[i];
totalSum += product;
O
}

System.out.println(totalSum);
}
KN

}
TE

2025
youtube.com/@teknouf
UBK ANNA
UF
O
KN
TE

OUTPUT : 5

2025
youtube.com/@teknouf
UBK ANNA
public class Main {
public static void main(String[] args) {
int[] A = {5,3};
int N = A.length;

int summitElevation = findSummitElevation(A, N);

UF
System.out.println(summitElevation);
}

public static int findSummitElevation(int[] A, int N) {


int summit = A[0];

for (int i = 1; i < N; i++) {


if (A[i] > summit) {
O
summit = A[i];
} else {
break;
KN

}
}

return summit;
}
}
TE

2025
youtube.com/@teknouf
UBK ANNA
def find_summit_elevation(A, N):
summit = A[0]

for i in range(1, N):


if A[i] > summit:
summit = A[i]
else:

UF
break

return summit

A = [1, 2, 3, 4, 3, 2, 1]
N = len(A)

summit_elevation = find_summit_elevation(A, N)
O
print(summit_elevation)
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
UF
O
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
def count_lowercase_letters(s):
count = 0

for char in s:
if char.islower():
count += 1

UF
return count

input_string = "teTinG"

lowercase_count = count_lowercase_letters(input_string)
print(lowercase_count)
O
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
def count_lowercase_letters(s):
count = 0

for char in s:
if char.islower():
count += 1

UF
return count

input_string = "teTinG"

lowercase_count = count_lowercase_letters(input_string)
print(lowercase_count)
O
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
public class Main {
public static void main(String[] args) {
String inputString = "Test String.";

int lowercaseCount = countLowercaseLetters(inputString);

UF
System.out.println(lowercaseCount);
}

public static int countLowercaseLetters(String s) {


int count = 0;

for (int i = 0; i < s.length(); i++) {


if (Character.isLowerCase(s.charAt(i))) {
O
count++;
}
}
KN

return count;
}
}
TE

2025
youtube.com/@teknouf
UBK ANNA
UF
O
KN
TE

2025
youtube.com/@teknouf
UBK ANNA
import java.util.*;
public class Main {

public static void main(String[] args) {


Scanner sc=new Scanner(System.in);
System.out.println("Enter the number of rounds:");
int n=sc.nextInt();

UF
System.out.println("Enter the moves:");
String str=sc.next();
System.out.println("The number of successful move by
A:"+checkA(str,n));
}

public static int checkA(String str,int n) {


int i=0;
O
int count=0;
for(int j=0;j<n;j++) {
if(str.charAt(i)=='s') {
KN

if(snakeorwater(str,i)) {
count++;
i=i+10;}
else {
if(str.charAt(i+5)=='s') {
i=i+10;
}
TE

else {
i=i+8;
}
}
}

2025
youtube.com/@teknouf
UBK ANNA
else if(str.charAt(i)=='w') {
if(snakeorwater(str,i)) {
count++;
i=i+8;
}
else
i=i+10;

UF
}
else {
if(gun(str,i)) {
count++;
i=i+8;
}
else {
if(str.charAt(i+3)=='w') {
O
i=i+8;
}
else
i=i+6;
KN

}
}
}
return count;
}
TE

2025
youtube.com/@teknouf
UBK ANNA
public static boolean snakeorwater(String str,int i) {
if(str.charAt(i)=='s') {
if(str.charAt(i+5)=='w') {
return true;
}
else

UF
return false;
}
else
{
if(str.charAt(i+5)=='g') {
return true;
}
else
O
return false;
}
}
public static boolean gun(String str,int i) {
KN

if(str.charAt(i+3)=='s') {
return true;
}
else
return false;
}
}
TE

2025
youtube.com/@teknouf
UBK ANNA
AFFORDABLE PLACEMENT MATERIALS

UF
O
69 X 6 = 414/- PAY ONLY
KN

249/-

TO GET 👆🏽
DM - 👇🏽
TE

INSTAGRAM.COM/TEKNO.UF

2025
youtube.com/@teknouf
UBK ANNA

You might also like