Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
What is the last digit of 3^2024?
- A. 1
- B. 2
- C. 3
- D. 5
Correct answer: A. 1
The last digits of powers of 3 cycle as 3, 9, 7, 1 with period 4; since 2024 is divisible by 4, the last digit is 1.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many strings of length 4 over the alphabet {0, 1, 2} have no two adjacent characters equal?
- What is the Z-function value sum over positions i = 1 to n-1 of the string abababab?
- How many index pairs i < j in [1, 2, 3, 4, 5, 6] satisfy that a[i] times a[j] equals a[i] plus a[j]?
- Which data structure supports inserting values and reporting the k-th smallest value in O(log n) time each?
- Which algorithm counts occurrences of a pattern p inside a text t in O(|t| + |p|) time?
- Which algorithm finds the longest palindromic substring of a string in linear time?